The Math of Leap Days
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."
There are no leap years. It's a conspiracy to cause IT nightmares and bratty kids who claim their age /= 4.
To offset political mods, replace Flamebait with Insightful.
and it only comes along every for years.
Wow! That really IS rare!
I think we have different definitions of complicated.
There's an extra working day! Woohoo!
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 ....
Slightly disreputable, albeit gregarious
On climagic I laid it out in less than 140 characters.
Does anyone else really dislike the way that font represents numbers, constantly bouncing up and down above and below the rest?
Oh wait, it ends in 2012!
-- By all means let's be open-minded, but not so open-minded that our brains drop out.
Our whole calendar is messed up. First- Jan 1st is a poor start date.
I suspect the original pioneers intended the year to start on the Winter Solstice- which is more like Dec 21st most years on our calendar.
So- The year should start on Dec21st.
Then- our months are supposed to be based on cycles of the moon (Approx every 28 days)- but because there were 13 and superstitious nitwits didn't like 13 we have 12 months with varying days.
Our current concept of a month is meaningless. The whole 7 day week is rather random too- based on some out-of-date dogma that is probably mistranslated. (the original word in Genesis translated as "day" was more accurately "a period of time" although it was often "day" but not necessarily) - so we force the meaning of "day" onto it and have a 7 day week. Silly number.
Let's make a week 10 days- a much more logical number.
So we have 36 weeks in a year. If we MUST have a bigger break- we can divide these into 9 months of 4 weeks each.
We would then have 5 or 6 days at the end- a "half week" - we would determine if it would be 5 or 6 days depending on how many days it took to reach the winter solstice since that would be the definition of new year.
Not perfect- but based more on logic than our current system and no-silly formulas needed (other than determining the solstice)
"That's the way to do it" - Punch
A year is not even exactly 365.2422 days long (if we could actually agree how long a "day" is).
Those who can make you believe absurdities can make you commit atrocities. - Voltaire
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.
How is this news? It's been in Wikipedia for years!
Have you heard about SoylentNews?
In Soviet Russia, leap year comes every time Politburo says it comes.
I much prefer the explanation in this video: http://www.youtube.com/watch?feature=player_embedded&v=xX96xng7sAE
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.
http://thedailywtf.com/Articles/DATE_NOT_FOUND.aspx
To give first-time programming students a fun and interesting homework assignment.
Hopefully no time soon, but almost certainly before 2100, when the next leap year doesn't happen. If due to lots of exercise, few pizzas and a whole bunch of luck we do survive that long, then we'll all be too dotty to know what day it is anyway. Glad this is sorted. All we have to know is that it happens every 4 years and will do for the entire rest of ever, so long as we care. Lets get coding and hardwire in a leap year to make the 2100 bug!
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.
The Kruger Dunning explains most post on
I wrote a leap-day calculator in PIC16 ASM about a decade ago as part of a weekday-on-a-given-date calculation. I don't think it was any more than 20 op-codes with one of the most limited ISA's that exists.
It's not complicated at all. Programmers only make mistakes because they don't do their research as to what exactly they're trying to calculate.
The answer to every programming Professor's favorite Intro. to Programming project assignment has now been leaked on the web! What will become of all the students who can now look up the formula to that mind-bending programming challenge of making a calendar application.
~theCzar
Won't work. The orbital period around the sun isn't constant. We're not (yet) locked in a fractional orbital sync with Jupiter, so its pull affects the nominal year length.
365.2421904 is a good approximation for right now, and the 4*25*4 rule is "good enough" for a while - locking it wouldn't make things better.
Plus, you don't really want the day to be in sync with the orbital year. Midday would not not occur at noon anymore, but shift, because perhelion doesn't happen at the same time of day every year.
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!
https://www.eff.org/https-everywhere
odd spelling too
Chose an aribitrary starting time, say the origin of this universe about 8 x 10^60 Plank units ago.
Where do you live that midday occurs at noon. The only guarantee is that midday and noon are within two hours of each other. This is due to timezones (roughly an hour wide) and daylight saving (shifting things off by an hour).
He effected a bored affect.
Although, you're talking about shift, which over time would put it further out of sync than it already is. I view that as a possibly good thing, then we can get rid of the timezones, and everyone uses GMT. That also means no more DST.
He effected a bored affect.
When code does not correctly model the problem domain, the error isn't with the domain.
And, not everyone has changed to the Gregorian calendar yet.
There's a few areas of European that refused to change from the Julian to the Gregorian, not because of any scientific reason, but because of a political reason. You see for quite a while, the main purpose of a complicated calendar was to keep track of when exactly Easter should be celebrated, and the different Orthodox churches quibbled about this. For a while, there was two different Easters, one for people on the Julian calendar, and one for people using the Gregorian.
The whole world changed to Gregorian, so they had to compromise. The compromise is one of the most hilarious developments in time tracking: the Revised Julian Calendar
Those who follow the Revised Julian Calendar never obey the "every 400 years" rule. Instead, they celebrate leap years every 4, unless the year is divisible by 100, unless the year is mod 900 is 200 or 600
The net result is that those countries were in agreemet with us retroactively in 1600, and in 2000, but the system will fall apart in 2400. The designers then get to live knowing that their principles have not been compromised, yet it will leave the fallout of the difference to their descendants.
Free unix account: freeshell.org
Oh, wait. I'm just an unoriginal fuckass. Might as well mod me into the stratosphere, though.
Well, an "oblig. xkcd" without a link or even an indication which one is meant, that is new as far as I can tell.
The Tao of math: The numbers you can count are not the real numbers.
You seem to have misunderstood the point the GP was making. If the computer internally stores the time as UTC then the stored time will always progress forward (UTC isn't affected by DST like GMT is), and behind the scenes it'll always be searchable. It's also about as future-proof as we can make it; if rules regarding leap years or calendaring in general change, you're screwed regardless of which system you're using. The DST translation should be done for display purposes only, based on the user's preferences for localization etc. Proper separation of content versus display logic should solve all of the problems you brought up. Those problems only become issues for people working with heterogeneous data sets (time stored differently in different data stores), in which case you'd expect to be writing translation routines anyways.
"Space Exploration is not endless circles in low earth orbit." -Buzz Aldrin
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.
No... no, there's not:
If the year is divisible by 4, then it’s a leap year, UNLESS
it’s also divisible by 100, then it’s not a leap year, UNLESS FURTHER
the year is divisible by 400, then it is a leap year.
Done.
If ((year modulo 4 is 0) and (year modulo 100 is not 0)) or (year modulo 400 is 0) Then
leapYear = true
Else
leapYear = false
End if
http://www.JetCityOrange.com/leap-year/
if (($yr % 400) == 0) $leapYear = true;
else if (($yr % 100) == 0) $leapYear = false;
else if (($yr %4) == 0) $leapYear = true;
else $leapYear = false;
So we're going to see this every four years? Except every hundred years? Except every four hundred years?
But how come our libraries aren't smarter about it.
Converting to a datetime shouldn't be so difficult. Neither should handling month short forms (Sept. I'm looking at you!) obviously we should be moving to metric time. (Five fingers FTW!).
Even 20 years ago November and December were winter, now it doesn't really get cold enough for snow until late December (in Canada)...
Screw the Romans, and screw the issues with daylight savings, how about some proper month representation.
365.24219878125
That's all, really.
If a leap year is a year that contains one extra day, then surely a leap day is a day that contains one extra second, as happens from time to time to adjust UTC for the earth's rotation. (The extra second is always added just before midnight.) But then, people call that a 'leap second', even though it is exactly the same length as any other second...
-- Ed Avis ed@membled.com
Naturally I couldn’t let this bit of maths go. I’ve made an overly complicated spreadsheet that generates correctly formatted wall planners. Initially I was happy that this nonsense happens every 4 years and will do for the useful period of the wall planner generator. Then I drank too much coffee and added the correction anyway. Assuming cell A1 contains the year of interest, this formula gives the number of days in February: =IF(MOD(A1,4)=0,IF(MOD(A1,100)=0,IF(MOD(A1,1000)=0,29,28),29),28)
Basic primary school knowledge in the discovery magazine and slashdot.
THIS SHOULD CLEAR IT UP:
“Of course, up until recently there was no such thing as number four.” Karnov says.
“Is that a euphemism?”
“No. I mean that the number sequence went one, two, three, five, six sevenAnd so on.”
“So there was no number four?”
“Not at all. It has been proven that a child named Boba Fett invented the number four. -And very recently too.”
Niall can’t believe he is hearing this. “But I remember the number four from my childhood!”
Rojic explains. “You say you do, but with things this fundamental, there is a group unconsciousness thing going on, and a racial memory block that prevents you from remembering the absence of the thing that now you can recall. -Whereas previously you didn’t, nay- couldn’t possibly. There was nothing to remember to forget and re-remember now that you have forgotten.”
“Thanks Rojic, you actually help more by not helping.”
Rojic flits off. “I’m off to repressurise the emergency re-pressurisation cylinders.”
“That’s easy for him to say.”
Niall and Karnov glower at one another.
Niall finally says. “When you're arguing with a fool, make sure he isn't doing the same thing.”
Karnov has the last laugh. “I think that actually says more about you than me.”
They both think about this, all the while trying not to prove one another wrong or right.
Finally, Niall says, “What did Rojic say he was going to do?”
“Something about re-melting the sausages.”
“That’s what I thought.”
Rojic shouts back through the hatch. “Not melting, smelting.”
In unison Niall and Karnov call back. “I’m smelting!”
TO READ THE REST, SEE:
http://homepage.ntlworld.com/anthonyandanna/Starwars/1.25.html
So it is true! A Young Boba Fett invented the number four in his early childhood - that'd be around 25 BBY then.
If you thought Our calendar was crocked, think about the star wars one: In which years are recorded up to an event in the future which has not yet happened! If you added a few leap years between the clone wars and the Battle of Yavin, you'd miss it by several days! -D'oh!
I vote for growing 3 extra fingers. Then we can use Base 13. The jokes are better.
Or it was a Dr Who reference ?
no math required. i wake up, and turn on the morning news. i know what day it is and the temperature. sweet!
Is there an editor in the room?
Once upon a time, my favorite interview question for prospective programmers was "How long does a year last?" This was around 2000, so leap year trivia was hot. The answer I wanted was for the candidate to break down the leap year rules and come up with 365.2422 or thereabouts.
It was depressing how many interviewees didn't even understand that a year is the time it takes the Earth to orbit the sun. Many confused the Earth's orbit and the Earth's rotation. Yes, some thought it took 24 hours to orbit the sun.
Can't we just change the orbit of the Earth so one year = 360 days?
The leap year calculation is a trivial one liner. I did this in BASIC in 1980 when learning programming.