-
-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update today
XPath function to not return current time
#7731
Comments
I agree that we should align to the ODK XForm spec, and that this is likely the best time to do so. That said, this will need revision of nearly all forms that use dates, so we should do everything possible to help app builders convert and verify their forms. |
@jkuester Thinking about 4.0.0 scheduling, are you planning to work on this? If so, when do you think you'll have time to get it ready? |
@garethbowen sorry for the late response here! My goal is to address this issue next week. Let me know if you think that will be too late on the |
@jkuester I think that'll be ok. archv3 AT will take some time. Please let me know if there's anything I can do to help make progress on this. |
@garethbowen as I go though our default/standard config and evaluate if anything needs changed, I just wanted to run my criteria by you and see if it sounds correct. Mostly it is pretty simple. For each place we are currently using
Where things become a bit complicated is when we have places where we are currently using It seems like the new behavior of |
This is ready for AT on https://github.com/medic/cht-core/tree/7731_refactor_today Basically the behavior of the So, the main thing to test here is that all of the forms listed below still behave exactly like they do in Edited forms: Default config
Standard config
|
Thank you very much @jkuester for all the details about the changes, this is really helpful because that way I know where to focus the testing. Using cht core version Tested forms for
Tested forms for
|
@jkuester I know I'm late to the party but I agree with your solution WRT timezones. Thanks! |
What feature do you want to improve?
Currently we have a custom implementation of the
today
functionality that is identical to what is returned by thenow
function (the current date and time in the current timezone).Describe the improvement you'd like
As noted in this OpenRosa issue (enketo/enketo#901), this behavior does not seem to follow the ODK Spec. Unfortunately, the wording in the spec is a little confusing (to me at least) with regards to how it is actually supposed to behave. However, both openrosa and javarosa have coalesced on a single interpretation of the spec where
now
returns the current date and time whiletoday
returns the current date with the time set to midnight of the current timezone. I think we should remove our custom implementation oftoday
and just use the one provided by OpenRosa.As things stand today, we have a bunch of forms that are doing things like
date(floor(decimal-date-time(today())))
to get the start of today. All this extra logic could be eliminated with the new implementation oftoday
. Any logic that relies on the current time being included intoday
can just update to the spec-compliantnow
function.As discussed in places like here, here, and here the Enketo uplift is already going to cause subtle behavior changes in the behavior of
format-date
anddecimal-date
(both frequently used along withtoday
). Changingtoday
at the same time as these other changes would allow projects to implement proper fixes to their date handling once and for all instead of breaking some things now with the Enketo uplift and again later if we decide to switch to a spec-compliant version oftoday
.Describe alternatives you've considered
One alternative would be to leave
today
alone and add a new custom function (e.g.today-date
) that would return today's date without a time value. This would be more passive and backwards compatible, but less spec-compliant.Additional context
This has been an ongoing saga in CHT code for years:
calculate="today()"
gets wrong date in certain timezones #1878#5831 was the PR that added the current custom functionality for
today
to cht-core.The big difference now is that both openrosa and javarosa seem to have agreed on an implementation (that is different from what we have).
The text was updated successfully, but these errors were encountered: