-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Date Calculation Does Not Factor In Leap Year #53
Comments
This is your friendly Microsoft Issue Bot. I created this issue automatically as requested by a team member. |
I believe that test case is incorrect. Per https://www.timeanddate.com/date/dateadded.html?m1=02&d1=20&y1=2019&type=add&ay=2&am=&aw=&ad=6&rec= the correct value was returned. When you add years, you do not convert them to days, you just add years. Does it reproduce when starting with Feb-1 and adding 31 days or Feb-28 00:00 and adding 25 hours? |
I agree with @benjaminkwilliams. I think it should be asked what does the user expect when a year is added to a date, if the next day in the next year or the 365th next day. I find it more likely to be the first one. Otherwise, the answer for adding y years to a date month/day/year would be month/day - leap years in that period of time/year+y, and saying that 20 years after 02/20/2019 is 02/15/2039 sounds odd to me. |
I agree with @benjaminkwilliams and @marcomontoya, a year is not defined as 365 days neither as "Earth doing a full loop around the sun (~365.24219 days)", but as the same the same day number and month but Year+1. We should also keep in mind that the Calculator application manages more than the Gregorian calendar. Think about birthdays or anniversaries, you don't celebrate your birthday 1 day before before the current year was a leap one. |
I concur, the calculator is behaving correctly. It is indeed taking leap years into account, by not treating a year as 365 days. This is akin to not every month being 30 days. In both cases, the calculator is doing the correct thing.
The issue should be closed. Thanks. |
Closing per conversation above. |
Describe the bug
The next occurring leap year is next year 2020! The actual Leap Day is Saturday Feburary 29th, 2020. In a recent round of tests with the Date Calculation I found that when adding days past the next leap day the calculation acted as if that day never existed and didn't account for the fact there is an extra day in the year. I set up the case with Today's date February 20,2019 and added 1 year, 0 months and 6 days. The answer came to be A February 26, 2020 just 3 days before Leap Day. I then added an extra year to the equation and got February 26, 2021, which normally that is fine but with leap year it would actually be February 25th, 2021 because of the extra day.
Steps To Reproduce
Expected behavior
Leap years are taken into account for date calculations.
Device and Application Information (please complete the following information):
Additional context
What is also interesting here is that normally the days of the week move forward one day from the previous, except in the case of leap year and then it is two for any date past Leap Day. So looking at this the days of the week has been adjusted for leap year, but the calendar date was not.
The text was updated successfully, but these errors were encountered: