-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Bug with DateTime and leap year #111021
Comments
Tagging subscribers to this area: @dotnet/area-system-datetime |
Then handling of leap date is very arbitrarily chosen and subjective. It also applies to |
FWIW, Java also uses this "incorrect" behavior:
Note that, while the behavior is technically arbitrary, retaining the same month is actually beneficial for "striding" implementation use. That aside, for this and similar month-to-month behavior, you should usually avoid end-of-month dates when possible, and I personally tend to regard any math on such values other than +/- days as concerning. You're usually better off working with start-of-month values. |
As designed. |
Description
If you add one year to 2024-02-29, the expected result differs from the actual result
Reproduction Steps
Create a console application
Expected behavior
It should print the first of March 2025 and not the 28th of February 2025.
VB6, JavaScript and more languages do it correctly.
Actual behavior
.NET outputs 28th of February 2025.
Regression?
No response
Known Workarounds
No response
Configuration
Tested on .NET 4.8 until .NET 9 on Windows x64 and in https://dotnetfiddle.net/Hxy8gt
Other information
No response
The text was updated successfully, but these errors were encountered: