Time picker with now()

Hi,

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.

Is there something obvious I’m missing?

Thanks,

Hi Tony,

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)?

-Clayton

Hi Clayton,

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.

Thanks,

Hi Tony,

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.

-Clayton

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.

Thanks again.

Hi Tony,

Thanks for confirming.

Can you share two things for me so I can put this on a long term bug board for the team?

  1. What locale are you in currently?
  2. 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.

-Clayton

Sure thing.

  1. Locale - do you mean my location? If so, California.
  2. I’m using using now() in the default value

Thanks,

Tony

Hi @Clayton_Sims -

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.

image

and the advance arrow gets greyed out preventing form submission

image

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

image

Hi Tony,

That’s really strange. I’m able to replicate this as well, I’ll file an internal support ticket to get this resolved.

Thanks for reporting this back up.

-Clayton

1 Like

Hi Tony,

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.

-Clayton

1 Like

Hi Clayton,

Just wanted to confirm that the update has fixed the issue(s).

Thanks :pray: