Sormas-project: Leap year error: Unable to save date of birth (29.02.1988)

Created on 5 Jun 2020  Â·  9Comments  Â·  Source: hzi-braunschweig/SORMAS-Project

Bug Description

As described above, if 29.02.1988 is entered as date of birth, the day remains empty.

Steps to Reproduce

  1. Create case or contact, or change date of birth of existing person to 29.02.1988
  2. Save changes
  3. See that day field remains clear

System Details

  • Device: Web
  • SORMAS version: 1.41
bug sormas-ui

All 9 comments

Funny bug!

@max-hzi What exactly is the problem here? 1998 was no leap year, so it's expected that 29.02.1998 can't be selected as the 29 isn't part of the dropdown.

@MateStrysewskeSym Yes, sorry, I meant 1988. The request I received was for 1988, I confirmed it in sormas with 1988 but incorretly typed 1998 in this Issue.
The problem remains in 1.42.3. Please re-open.

What I see, PersonEditForm.updateListOfDays() is called twice during loading.

The first time (when the month is set in the form) with year=null and month=2. That sets the list with 1 to 28 (it uses year 2010 https://github.com/hzi-braunschweig/SORMAS-Project/blob/89ab3c4b334a8197d05649f3fb59ee53f2d06e62/sormas-api/src/main/java/de/symeda/sormas/api/utils/DateHelper.java#L256) → when the select is updated https://github.com/hzi-braunschweig/SORMAS-Project/blob/89ab3c4b334a8197d05649f3fb59ee53f2d06e62/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonEditForm.java#L455 sets the value to null

The second time (when the year is set in the form) with year=1988 and month=2. That sets the list with 1 to 29, but the value is has been lost previously → the value is still null.

Edited the original post to match the reported problem.

I verified that is not caused by an order or lambda induced problem made ourselves.

The problem is happening after binding and persisting on the re-bind to update the view (or opening the view with data loade from the backend)
The binding binds in this order birthdateDD (1), birthdateMM (2), birthdateYYYY (3) (alphanumeric order), and step 2 resets birthdateDD prior the year can be evaluated in the form.
Possible workaround: Allow "Feb 29" when year == null in DateHelper.getDaysInMonth.

Possible workaround: Allow "Feb 29" when year == null in DateHelper.getDaysInMonth.

Agreed with @MateStrysewskeSym that is the way to go.

I tested it successfully for create and edit. It is already merged on development.
@MateStrysewskeSym please review.

Was this page helpful?
0 / 5 - 0 ratings