lucavandro / CodiceFiscaleJS

CodiceFiscale.js is a utility library to compute and validate Italian Tax code (codice fiscale).
Creative Commons Attribution Share Alike 4.0 International
197 stars 77 forks source link

Wrong date of birth #84

Closed pchlsn90 closed 2 years ago

pchlsn90 commented 2 years ago

Hi, I found an issue, if you put the timezone of the pc on a timezone in next day (i.e. from Italy you put Fiji) you'll receive a wrong date of birth.

example: CF: **73H67D08** birthDay: 26/06/1973 (the correct date is 27/06/1973)

the current hour in italy at the time oh the screenshot is 09/06/2022 09:40

image
pchlsn90 commented 2 years ago

I analized the 'reverse' function, a possible solution is to transform this line: this.birthday = new Date(Date.UTC(year, month, day, 0, 0, 0, 0)) in: this.birthday = new Date(year, month, day, 0, 0, 0, 0)

pchlsn90 commented 2 years ago

I also found this solution on stack owerflow: https://stackoverflow.com/a/16048201

lucavandro commented 2 years ago

Thank you for your report. This issue will be fixed starting from v.2.3.19