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

Date Calculation Does Not Factor In Leap Year #53

Closed
MicrosoftIssueBot opened this issue Feb 27, 2019 · 6 comments
Closed

Date Calculation Does Not Factor In Leap Year #53

MicrosoftIssueBot opened this issue Feb 27, 2019 · 6 comments
Assignees
Labels
Area: User Experience Issue primarily affects end user experience and are not covered by other areas by design This issue or pull request already exists Pri: 1

Comments

@MicrosoftIssueBot
Copy link
Collaborator

MicrosoftIssueBot commented Feb 27, 2019

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

  1. Launch the Calculator app build 10.1812.10048.0.
  2. Navigate to Date Calculation.
  3. From the drop down field select Add or subtract days.
  4. For the from date enter February 20,2019
  5. Check the bubble Add
  6. Enter 1 Year, 0 Months, 6 Days.
  7. Take Note of the date Wednesday, February 26,2020 (3 days before Leap Day)
  8. Change Years field from 1 to 2.
  9. Observe new date Friday, February 26, 2021.

Expected behavior
Leap years are taken into account for date calculations.

Device and Application Information (please complete the following information):

  • OS Build Number:
  • Architecture: x64
  • Application Version Number: 10.1812.10048.0

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.

@MicrosoftIssueBot MicrosoftIssueBot added Area: User Experience Issue primarily affects end user experience and are not covered by other areas Pri: 1 triage approved Issue has been approved by Calculator team member Bug Issue is a bug labels Feb 27, 2019
@MicrosoftIssueBot
Copy link
Collaborator Author

This is your friendly Microsoft Issue Bot. I created this issue automatically as requested by a team member.

@grochocki grochocki added the help wanted Issues identified as good community contribution opportunities label Mar 6, 2019
@benjaminkwilliams
Copy link

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?

@ChascaNeperiana
Copy link
Contributor

ChascaNeperiana commented Mar 7, 2019

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.
However, if we stick to the definition of adding a year that Benjamin and I propose, it would be still needed to define what date is a year after any February 29th.

@rudyhuyn
Copy link
Contributor

rudyhuyn commented Mar 9, 2019

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.

@mattjohnsonpint
Copy link

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.

  • Consider March 31st (of any year) plus one month. The result cannot be April 31st, because April only has 30 days. So the result becomes April 30th.
    • Advancing to May 1st would not make sense in most cases - as we started in March so expected to end in April.
  • Now consider February 29th 2020 plus one year. The result cannot be February 29th 2021, because in that year February only has 28 days. Thus, the result is February 28th 2021.
    • Advancing to March 1st 2021 would not make sense in most cases - as we started in February so expected to end in February.

The issue should be closed. Thanks.

@grochocki
Copy link
Contributor

Closing per conversation above.

@ghost ghost removed the help wanted Issues identified as good community contribution opportunities label Feb 11, 2020
@grochocki grochocki added by design This issue or pull request already exists and removed triage approved Issue has been approved by Calculator team member labels Feb 11, 2020
@MicrosoftIssueBot MicrosoftIssueBot removed the Bug Issue is a bug label Mar 30, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: User Experience Issue primarily affects end user experience and are not covered by other areas by design This issue or pull request already exists Pri: 1
Projects
None yet
Development

No branches or pull requests

8 participants