Skip to content

Fix replacedate to handle empty input; see Issue #192#256

Open
tomio13 wants to merge 6 commits intosplitbrain:masterfrom
tomio13:datefix
Open

Fix replacedate to handle empty input; see Issue #192#256
tomio13 wants to merge 6 commits intosplitbrain:masterfrom
tomio13:datefix

Conversation

@tomio13
Copy link

@tomio13 tomio13 commented Oct 27, 2018

DATE() will return 1970-01-01 for an empty input. Now, if using a year or part of the date to create namespaces dynamically, this can throw things quite off. This patch adds a check if the supplied date is empty or the strototime() throws an error, and returns an empty string for this case.

This behavior is especially useful for complex forms, where multiple input is possible for the date, and either one or the other is valid only. In my example, running projects and planned projects evaluate differently, and the namespace is composed dynamically based on the input.

DATE() will return 1970-01-01 for an empty input. Now, if using a year or part of the date to create namespaces dynamically, this can throw things quite off. This patch adds a check if the supplied date is empty or the strototime() throws an error, and returns an empty string for this case.

This behavior is especially useful for complex forms, where multiple input is possible for the date, and either one or the other is valid only. In my example, running projects and planned projects evaluate differently, and the namespace is composed dynamically based on the input.
I am using it in a setting where the created forms are sorted
according to entry year, but in special cases, planned content
has no date. The original would throw the planned content to year
1970, which is a very much not desired behavior.
Now the replacedate() will return empty string for empty input.

P.s.: I am new to github and have difficulties getting my commit
submitted properly. I am sorry if i am generating noise. T.
@splitbrain
Copy link
Owner

can you remove the patch file from the PR please?

@tomio13
Copy link
Author

tomio13 commented Oct 29, 2018 via email

@tomio13
Copy link
Author

tomio13 commented Jan 11, 2019

Any reason why this does not get merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants