Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

birthday throwing exception if run at 2/29/2024 #1103

Closed
gregma opened this issue Feb 29, 2024 · 7 comments
Closed

birthday throwing exception if run at 2/29/2024 #1103

gregma opened this issue Feb 29, 2024 · 7 comments

Comments

@gregma
Copy link

gregma commented Feb 29, 2024

Describe the bug
When attempting to create a birthday today (This is a leap year and it's 2/29/2024.) I get the following:
Invalid date 'February 29' as '2006' is not a leap year

To Reproduce
faker.date().birthday(18, 60, "M/d/yyyy")

Expected behavior
Faker to generate a birthdate

Versions:

  • OS: Windows 11
  • JDK - jdk1.8.0_211
  • Faker Version - 2.1.0

Additional context
When using calculations, if the date of one of the variables happens to not be a leap year, then it should automatically change to the 28th, and not throw the exception.

@gregma gregma changed the title Leap year using 2006? birthday throwing exception if run at 2/29/2024 Feb 29, 2024
@snuyanzin
Copy link
Collaborator

closing as duplicate #1098
it was fixed almost a half a year ago at #954
please use 2.0.2 or 2.1.0+

@snuyanzin
Copy link
Collaborator

snuyanzin commented Feb 29, 2024

OS: Windows 11
JDK - jdk1.8.0_211
Faker Version - 2.1.0

Frankly speaking I do not trust this description
Faker 2.0+ requires java 17, so you can't test 2.1.0 with java 8

@gregma could you please verify that you test with the correct versions?

@kingthorin
Copy link
Collaborator

I've just run ./mvnw test a bunch of times on my dev box (with latest code). It does seem that today (leap day) is causes an issue in some cases. But it's intermittent; I get a few good runs, a few bad runs. The failures seem to be consistently these types of messages:

[ERROR] �[1;31mFailures: �[m
[ERROR] �[1;31m  DateAndTimeTest.testBirthday:132 
Expecting actual:
  -342046201694L
to be greater than or equal to:
  -342039600000L
  
[ERROR] �[1;31m  Run 29: FakeValuesServiceTest.futureDateExpression:309 
Expecting actual:
  2024-03-10T10:58:16.842 (java.time.LocalDateTime)
to be between:
  ]2024-02-29T10:33:20.553472851 (java.time.LocalDateTime), 2024-03-10T10:33:20.553472851 (java.time.LocalDateTime)[
when comparing values using 'ChronoLocalDateTime.timeLineOrder()'

@snuyanzin
Copy link
Collaborator

This is test only related issue
should be fixed with #1100
can you please double check?

@kingthorin
Copy link
Collaborator

kingthorin commented Feb 29, 2024

Re-checking now. I'm guessing you're right on the testBirthday occurrence. git log -1 was showing codecov as my latest merge so that woulda been the 26th I guess.

@kingthorin
Copy link
Collaborator

Just re-ran 6 times. Didn't get any failures from testBirthday so it looks like you've addressed that.

Did still get one from futureDateExpression, but I guess that's unrelated.

@snuyanzin
Copy link
Collaborator

snuyanzin commented Feb 29, 2024

thanks for checking

Did still get one from futureDateExpression, but I guess that's unrelated.

I didn't get it however it might be there is a similar issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants