jsonforms icon indicating copy to clipboard operation
jsonforms copied to clipboard

Angular date picker: selected date is off by one day

Open TheMicDiet opened this issue 3 years ago • 2 comments

Describe the bug

When selecting a date from the date picker the date form field value is set to one day before the selected date. For example, choosing 9.10.2022 from the picker will result in 8.10.2022 being displayed in the date form field.

Expected behavior

The correct date value should be set, i.e., the date set and displayed in the date form field should match the selected date from the picker.

Steps to reproduce the issue

  1. Open the date picker on a date field.
  2. Click on any day.
  3. See the value in the date field is off by one day compared to the day previously clicked on.

Screenshots

No response

In which browser are you experiencing the issue?

Google Chrome 106.0.5249.103

Framework

Angular

RendererSet

Material

Additional context

This issue occurs both in my own app and on the JSONForms Angular Material Playground (https://jsonforms-angular-seed.netlify.app/).

TheMicDiet avatar Oct 09 '22 16:10 TheMicDiet

Possible cause: Maybe some time zone shenanigans are interfering here. For example it could be that we set the time to 00:00 of the selected day, but because of some automatic timezone consideration the day is then calculated to the day before.

sdirix avatar Oct 13 '22 09:10 sdirix

I think you’re right. If I change my time zone to UTC, the date is correct.

TheMicDiet avatar Oct 13 '22 10:10 TheMicDiet