Giter VIP home page Giter VIP logo

Comments (6)

benjaminkwilliams avatar benjaminkwilliams commented on May 18, 2024 1

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?

from calculator.

MicrosoftIssueBot avatar MicrosoftIssueBot commented on May 18, 2024

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

from calculator.

ChascaNeperiana avatar ChascaNeperiana commented on May 18, 2024

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.

from calculator.

rudyhuyn avatar rudyhuyn commented on May 18, 2024

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.

from calculator.

mattjohnsonpint avatar mattjohnsonpint commented on May 18, 2024

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.

from calculator.

grochocki avatar grochocki commented on May 18, 2024

Closing per conversation above.

from calculator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.