I have a separate date and time picker in my form. I'm trying to define the current date and time as default value for each of the question to minimize the need to scroll and find the actual date and time.
Today() works fine as the default for the date picker. However, for the time I'm using now() which works except for the fact that it's 1 hour off and is the same on a mobile device, webapp, or in the app preview.
There was a bug that was fixed recently that could cause an off-by-an-hour issue on some devices due to DST offsets. Are you on the latest CommCare release (2.50)?
Thanks for the response. My android device is running CommCare 2.50.2 and I just changed the build settings to 2.50.1 in CommCareHQ and redeployed. Still getting the same off-by-an-hour bug.
One question: The default behavior of the time widget is to use the current time for the user without needing to have that initialized as a default value.
Have you tested that behavior? I'm not quite sure what would be off about configuring it from now(), but the fastest way to get to the correct behavior is likely to simply not set a default value at all.
Thanks Clayton. Interestingly, on the app it works as you described without defining the default value. However, we're using web apps and the behavior without defining the default appears to be rounding to the nearest hour. So, if it's 15:34 it'll default to 16:00 and if it's 15:29 it'll default to 15:00. A minor issue that I think we can live with.
Can you share two things for me so I can put this on a long term bug board for the team?
What locale are you in currently?
what expression were you using to generate the default value for the Time question?
Additionally, I can check with the product team on the browser behavior for the Time question as well, just in case it wasn't intended for it to round.
I also just noticed an odd behavior / bug with the time picker and app preview. More specifically it looks like in App Preview if a time is selected it prevents the form to be submitted. The question just gets stuck with the loading arrow sign.
and the advance arrow gets greyed out preventing form submission
There is no default value defined in the question properties and it is not marked as required.
If the time question is left blank it allows me to continue
Just a heads up that I figured out what was going on here and we are hoping to deploy the fix for the problem this evening (US Eastern time). I believe it should also fix your earlier reported issue about setting the time with 'now()' to get the precise hour and minutes.