Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
Math Science

The Math of Leap Days 225

The Bad Astronomer writes "We have leap days every four years because the Earth's day and year don't divide evenly. But there's more to it than that... a lot more. A year isn't exactly 365.25 days long, and that leads to needing more complicated math and rules for when we do and don't have a leap year. If you've ever wanted to see that math laid out, now's your chance, and it only comes along every four years. Except every hundred years. Except every four hundred years."
This discussion has been archived. No new comments can be posted.

The Math of Leap Days

Comments Filter:
  • Duh. (Score:4, Funny)

    by masternerdguy ( 2468142 ) on Wednesday February 29, 2012 @03:21PM (#39201603)
    There are no leap years. It's a conspiracy to cause IT nightmares and bratty kids who claim their age /= 4.
    • Its not that hard (Score:5, Interesting)

      by suso ( 153703 ) * on Wednesday February 29, 2012 @03:29PM (#39201703) Journal

      On climagic I laid it out in less than 140 characters. [twitter.com]

      • Re: (Score:2, Funny)

        by Anonymous Coward

        ARRGH, a twitter feed I acutally want to follow.

    • A year is not even exactly 365.2422 days long (if we could actually agree how long a "day" is).
      • The 3/1000 difference from .2425 to .2422 results in a Y30K problem. After 30,000 AD, we can relax for a while.
        • The 3/1000 difference from .2425 to .2422 results in a Y30K problem. After 30,000 AD, we can relax for a while.
          Due to tidal forces slowing the Earth's rotation, in the year 30,000, the day will be about half a second longer resulting in the year being only 365.2401 days long, so we will need to adjust our algorithms a lot sooner than that
          • by mwvdlee ( 775178 )

            If the days would become shorter, that means we'd be able to drop the %400 rule somewhere between now and Y30K, but since a day is actually slightly longer than what our current algorithm accounts for, the two might just cancel eachother out to let the algorithm last well beyond 30K. I'm too lazy to try and do the math to verify.

    • Not that much of a Nightmare, at least with modern Data classes. You take the month and year you are looking at. date(Year, Month+1, Day = 1) - 1 day. Then you get the last day of every month. Leap Year isn't the nightmare, The nightmare is the normal Month system with different days each month.
      • Re:Duh. (Score:5, Informative)

        by kirkb ( 158552 ) on Wednesday February 29, 2012 @04:50PM (#39202649) Homepage

        No, the REAL nightmare for programmers is daylight savings time. Especially in the spring, when local times jump back and repeat. Ugh.

        • Re:Duh. (Score:5, Insightful)

          by egamma ( 572162 ) <egamma@gma[ ]com ['il.' in gap]> on Wednesday February 29, 2012 @04:57PM (#39202717)

          No, the REAL nightmare for programmers is daylight savings time. Especially in the spring, when local times jump back and repeat. Ugh.

          That's why you should save the time in UTC format, and then let the OS help you translate that into a display time.

          • by EdIII ( 1114411 )

            It is still a nightmare though. Just for a different programmer and not you. You have to approach the problem by reading the time first, then deciding on how to store it. That means you need to rely on that system, and some may be better than others. I would think most systems are relying on Linux and the zoneinfo files to get the time correctly.

            So some programmer still needs to deal with the fallout from the fucktarded Congress Critters that decided to tank millions of devices worldwide that depended o

            • Time should be like internationalization. Everything internally is UTC or at last based on something other than local time; and strings are all multibyte. Everything is passed around this way untouched, uninterpreted. The only time you deal with locale settings is just before outputting the values and just after inputting them.

              And yet people keep getting this wrong... You end up with a customer whose facilities straddle a time zone boundary, or the server and client are in different time zones, and then

          • Twice a year I get marketing people coming to me and asking what happens to the product that doesn't have a certain bug fix. And twice a year they write it down, and promise to get some QA to test it to be really sure.

            Everything should be in UTC. Except that we have to integrate with products that insist on local time. Or bizarre time formats.

          • Re:Duh. (Score:5, Informative)

            by batkiwi ( 137781 ) on Wednesday February 29, 2012 @09:22PM (#39204685)

            Here is one the UTC/DST problems in a nutshell, and why it's not as simple as you think:
            Assumptions:
            -Me and my user are in UTC +10
            -DST puts us into UTC +11
            -DST runs from 1 October until 1 April

            I am writing a "family reminders" application for mobile phones. A user enters two reminders. BOTH reminders are activated for the user and his wife, reminding them to take some medication. One is for 10 March 2010 at 1130AM and the other is for 10 April 2010 at 1130AM.

            How do I store these date? I am a SMART programmer, and I store them as 2012-03-10_0030 and 2012-04-10_0130.
            I was clever. I looked at the user's timezone setting, projected into the dates they were setting to appropriately modify the UTC time depending on DST or not.

            Two things happen:
            1. The user's wife flies to the west coast on 9 march, 3 hours earlier. On 10 march, do we alarm her at 8:30, per UTC? Or do we look at her new current time zone vs when it really was set and alarm her at 11:30 local time?

            2. The "making summer longer" act is passed, extending DST to 15 April. Do we alarm them at 11:30am, or at 12:30pm? Why?

            The solution to both of these is to give the users a bunch of checkboxes they don't quite understand, or to make assumptions that might wind up incorrect. Either way there's no "win win".

  • For years (Score:5, Funny)

    by Sez Zero ( 586611 ) on Wednesday February 29, 2012 @03:22PM (#39201619) Journal

    and it only comes along every for years.

    Wow! That really IS rare!

    • The slashdot editors were probably just reading an alien cookbook and got confused.
    • for(int years = 0; years LENTH_OF_UNIVERSE; i++) { /* article */ }

    • Re: (Score:2, Funny)

      by Anonymous Coward

      That must be the American spelling: there's no "u".

    • The person who wrote the summary was a math wiz, not an english major.
    • It's just long enough that the original devs probably thought "I don't want to deal with this just yet" and put in a broken time system. Then 3 years later those devs are long gone when the bug reports start flooding in.

  • Complicated? (Score:5, Insightful)

    by Anonymous Coward on Wednesday February 29, 2012 @03:22PM (#39201621)

    I think we have different definitions of complicated.

    • by Meshach ( 578918 ) on Wednesday February 29, 2012 @03:33PM (#39201769)

      I think we have different definitions of complicated.

      Evidently spelling and grammar top the list for the /. editors.

    • Well, even when it was just a leap year every 4 years, folks managed to get it wrong, and only in 4AD someone pointed out the error in how the recommendations of mathematicians/astronomers employed by Julius Caesar had been interpreted. Between the reform (45BC) and 4AD leap years happened once per 3 years.

  • I'm pretty sure the math doesn't go anywhere. It's not Brigadoon.

    In fact I'm going to take the URL and put it in my calendar for next June.

    Will report back ....

  • Oh wait, it ends in 2012!
  • One of my first projects in Computing and Algorithms I in college was to make a calendar that would print out in console with days correctly placed on the day of the week. The instructions specified to take special care for leap day; everyone thought they understood leap day, so no one bothered to check on the rules. The fact that round centuries do not include a leap day except when (year mod 400 = 0) meant that every one of our calendars[1] was wrong for certain years (but right for others, IIRC). And our professor docked us points as such. Back then, the entire class (along with myself) felt that we were misled or cheated, but looking back on it now that was an important lesson on project management, specifically researching requirements and checking with the interested party about how things are.

    I reckon this lesson was missed by many, which leads to the various issues we see for software on Leap Day, including Microsoft's Azure as mentioned in a recent /. article.

    [1] For the half of the class that completed the project, this 101 class was used to weed out those who couldn't actually program for crap and the EEs just needed a C to meet their requirement.

  • Wait, what? (Score:5, Funny)

    by Jorl17 ( 1716772 ) on Wednesday February 29, 2012 @03:32PM (#39201759)
    How is this news? It's been in Wikipedia for years [wikipedia.org]!
    • by pz ( 113803 )

      Today is Feb 29, a leap day, that's why it's relevant. Tomorrow, it will be far less so.

  • by Kenosti ( 72451 ) on Wednesday February 29, 2012 @03:34PM (#39201785)
    I much prefer the explanation in this video: http://www.youtube.com/watch?feature=player_embedded&v=xX96xng7sAE [youtube.com]
  • Four days too late! (Score:5, Informative)

    by Guppy06 ( 410832 ) on Wednesday February 29, 2012 @03:38PM (#39201831)

    The extra, or "bissextile" day is actually inserted immediately after February 23.

    The Romans picked up the Egyptians' idea of treating a common year as 360+5 days, since 360 is a highly composite number and all (the Mayans ended up doing the same). But instead of treating the extra 5 days as "epagomenal" (outside any month), they were treated as the last five days before the first month of spring, i. e. the last five days of February.

    Treating the five-day block of Feb 24 through Feb 28 as inviolate meant inserting the extra day (previously an extra month) before it.

    This is why the Christian feast of Saint Matthias has historically been observed on February 24 in common years and February 25 in leap years; it's always the fifth ("sixth," if you lack an understanding of zero) day before the calends of March.

  • To give first-time programming students a fun and interesting homework assignment.

  • Whats with all the leap stuff?
    Yes, I know it's a leap year, but the only other time I remember seeing so much stuff about it being circulated was in 2000.
    Still, why are adults explaining it to other adults? Is this one different? Is the world getting so mellow that a leap year is no an excuse for a lengthy discussion on a reletivly trivial event? Trivial in that the rules are pretty simple. Not trivial as in little impact.

  • There's a very, very simple solution to this, and that is: At some value UTC, we all light model rocket engines with the exhaust facing east, and slow down the day such that its length goes evenly into a year. Any over/undershoot in the quantity or duration of burns can be adjusted on a much smaller scale. After that we just perform regular burns in the opposite direction to maintain angular momentum. Voila!

  • Chose an aribitrary starting time, say the origin of this universe about 8 x 10^60 Plank units ago.

Many people are unenthusiastic about their work.

Working...