• Youri (unregistered)

• Nagesh-saki (unregistered)

This should be a holiday

(There is a f-word I am missing)

• (cs)

I say they just subtrack 662709600000 (If my math is right) from the current Unix timestamp. 21 Years exactly.

• Bernard Kerckenaere (unregistered) in reply to PiisAWheeL

That depends on the number of leapyears there's in those past 21 years.

• (cs) in reply to Bernard Kerckenaere
Bernard Kerckenaere:
That depends on the number of leapyears there's in those past 21 years.

I think I calculated for it. 21365.25246060*1000=662709600000

• (cs)

This makes me wonder why the Euros are all pushing for a metric calendar. I mean the Leap Year problem is a pretty good example why the Gregorian Calendar should be considered harmful.

• Y2K (unregistered)

The first example is just plain stupid. The second example is more subtle and I can almost excuse it.

What most people don't realize is that the year 2000 was an exception to the leap year rules and had it been 1900 or 2100 it would NOT have been a leap year.

I suspect most programs got "lucky" in Y2K.

captcha: facilisis: Your understanding of how leap year is calculated will facilisis in releasing the correct code.

• Therac-25 (unregistered) in reply to frits
frits:
This makes me wonder why the Euros are all pushing for a metric calendar. I mean the Leap Year problem is a pretty good example why the Gregorian Calendar should be considered harmful.

What other solutions are there for the problem? i.e. the rotation of the earth is not in perfect sync with it's orbit, so you can't create a measurement of the orbit that is perfectly factored by a measurement of it's rotation.

• (cs) in reply to frits
frits:
This makes me wonder why the Euros are all pushing for a metric calendar.
We are?
• szeryf (unregistered)

“There are only three hard things in Computer Science: cache invalidation, naming things, and handling of the 29th of February."

• Anon (unregistered)

It's a leap day miracle!

Just not all miracle are good.

• Tractor (unregistered)

Dang, now booleans can have four values. It just keeps getting more and more complex.

• Nagesh-saki (unregistered) in reply to szeryf
szeryf:
“There are only three hard things in Computer Science: cache invalidation, naming things, and handling of the 29th of February."

Based on a couple articles back, the fourth hard thing is determining if a document contains any words from a list.

• nerd (unregistered)

Happens to me every weekend: "DATE_NOT_FOUND"

• notme (unregistered)

The closest thing I know to a "metric calender" would be the discordian one. And that one was dreamt up in America.

(It has leap years, but refuses to assign an actual date to the extra day. Instead, it inserts a "St. Tib's Day" between Chaos 59 and Chaos 60, "Chaos" being the name of the first of five 73-day months.)

• (cs) in reply to notme
notme:
The closest thing I know to a "metric calender" would be the discordian one. And that one was dreamt up in America.

(It has leap years, but refuses to assign an actual date to the extra day. Instead, it inserts a "St. Tib's Day" between Chaos 59 and Chaos 60, "Chaos" being the name of the first of five 73-day months.)

There's that one the Frenchies used, but we don't usually care about what they do.

• Gruntled Postal Worker (unregistered) in reply to frits
frits:
This makes me wonder why the Euros are all pushing for a metric calendar. I mean the Leap Year problem is a pretty good example why the Gregorian Calendar should be considered harmful.

In other news about Europe: It is said that Napoleon has departed with his great army towards Moscow, on a campaign to overthrow the last great King in continental Europe, the Russian Czar. Given the massive difference in military power, victory is almost assured.

• Jed (unregistered)
int intDay = (DateTime.Now.Day); int intMon = (DateTime.Now.Month); int intYear = (DateTime.Now.Year - 21);
Nice race condition there.

Call that code a few nanoseconds before midnight Jan 31. You may well end up with intDay == 31, intMon == 2.

• (cs) in reply to notme
notme:
The closest thing I know to a "metric calender" would be the discordian one. And that one was dreamt up in America.

(It has leap years, but refuses to assign an actual date to the extra day. Instead, it inserts a "St. Tib's Day" between Chaos 59 and Chaos 60, "Chaos" being the name of the first of five 73-day months.)

Here is a (probably not complete but maybe) list of calendars.

http://en.wikipedia.org/wiki/List_of_calendars

As for the discordian calendar... I'm not sure if I love it or hate it.

Who the hell is St. Tib?

• modo (unregistered)

The article explains the puzzle about 2/29 awesomely!

• Balkar (unregistered)

Who the hell is St. Tib?

Didn't he captain the USS Enterprise?

• (cs) in reply to Tractor
Tractor:
Dang, now booleans can have four values. It just keeps getting more and more complex.
Sad thing is in reality thanks to quantum computing our booleans might actually have more than 2 values. On, Off, Both, Neither.
• Machtyn (unregistered)

Eric's example is a poor demonstration on the necessity to create as many lines of code to satisfy business metrics as I've ever seen. It's way too efficient to pass the million lines needed to satisfy the project requirements.

//ugh, feel dirty now. really? they thought converting DateTime to int to string back to DateTime was the correct solution?

• Unicorn #8157 (unregistered) in reply to Therac-25

Well, any of the leap week calendars (http://en.wikipedia.org/wiki/Leap_week_calendar) handle it while maintaining more easy-to-follow rules. I'm a big fan of the Hanke-Henry permanent calendar, personally.

• ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to Y2K
Y2K:
What most people don't realize is that the year 2000 was an exception to the leap year rules and had it been 1900 or 2100 it would NOT have been a leap year.
Back in 1998, just before Y2K was all the rage, I knew this. And I fixed the code in our embedded system to properly handle the year 2000. Except that it was in assembly language. And I got a branch condition backward. And it broke leap years completely. So it wouldn't have worked in 2004, 2008, etc. Of course I only tested for 2000. Fortunately this was discovered in 1999, when Y2K was all the rage.

And just this morning, I sat down at my desk, looked at my current (and completely different) embedded system, and saw "February 28" on the screen. I freaked out. I turned on another unit that was temporarily in my cubicle and saw that it was also Feb 28. I had a bit of extra freak out to see that the time zone had changed too, but that was due to testing a settings file on both units. Then I noticed that both of them were off by 12 hours and I really freaked out trying to figure how this could happen in a system that used a longint seconds RTC.

Then I remembered how easy it was to forget to set AM/PM, and that probably both my desk unit and this other unit had the AM/PM wrong weeks ago, and the date was set in the afternoon. I probably wouldn't have even noticed the wrong date if it weren't Feb 29. So I got all freaked out by a non-bug on Feb 29.

And let us not forget The Day The PS3 Died. Back in 2010, due to a bug in the RTC chip (which didn't use longint seconds, but used the low BCD digit of the year mod 4 to determine leap years, WTF?), the RTC said the date was Feb 29 2010, while the hypervisor knew that the date was Mar 1 2010, so you couldn't log into PSN.

• (cs)
...my client is an alcohol company, and I run their website. They have a members-only section of their site that requires that you to enter your birthdate.
Why? Is there porn there?
• Anonymous (unregistered)

Not my code but a library I use (python-beaker):

```_delete_cookie(self):
snip
expires = datetime.today().replace(year=2003)
snip
```
*facepalm*
• Sobi (unregistered) in reply to Therac-25
Therac-25:
frits:
This makes me wonder why the Euros are all pushing for a metric calendar. I mean the Leap Year problem is a pretty good example why the Gregorian Calendar should be considered harmful.

What other solutions are there for the problem? i.e. the rotation of the earth is not in perfect sync with it's orbit, so you can't create a measurement of the orbit that is perfectly factored by a measurement of it's rotation.

Clearly, you did not understand the root problem here. Why should a year be the revolution time of the earth ?

Shift your paradigm and there is a simple solution to this problem: make 1 year last 4 years! So from now on, let's just say 1 year is 365*3+366 days (1461 according to calc.exe).

Of course, there will always be a few people reminding that every century (remember, a century is now 25 of your old years) there will be an adjustment. And hence they will pretend my idea is not valid.

But there is a solution ! Simple ! Let's make 1 year last 25 years.

Still there will be a problem every four years (because of the adjutment every 400 old years)... I'm working on it.

• blueg3 (unregistered) in reply to Anketam
Anketam:
Sad thing is in reality thanks to quantum computing our booleans might actually have more than 2 values. On, Off, Both, Neither.

More than four, but none of them are "neither".

For a one-qbit system, 0 and 1 are orthogonal basis vectors that form its state space. The qbit's state can be any unit vector in that state space.

An eight-qbit entangled system has 256 orthogonal basis vectors: |00000000>, |00000001>, ..., |11111111>. The eight-qbit system can occupy any state that is a unit vector in that 256-dimensional state space.

So.

• (cs) in reply to PiisAWheeL
PiisAWheeL:
Bernard Kerckenaere:
That depends on the number of leapyears there's in those past 21 years.

I think I calculated for it. 21365.25246060*1000=662709600000

And your code will be long gone in 88 years when this fails.

• blueg3 (unregistered) in reply to Sobi
Sobi:
Why should a year be the revolution time of the earth ?

Because that's the definition of a year. What you're proposing is to make something other than a year the unit for long-term time measurement.

The reason that's a bad idea is that proposals that confuse everyone except for incompetent computer programmers generally fail.

• Tud (unregistered)

90% of WTFs seem to be just programmers who don't know there is a function to do something and instead have to do a (poorly-designed) workaround.

That's why I spend 30 minutes re-reading the whole Python documentation before writing any new function.

• (cs) in reply to boog
boog:
...my client is an alcohol company, and I run their website. They have a members-only section of their site that requires that you to enter your birthdate.
Why? Is there porn there?
No, but there is violence. It's an alcohol company after all.
• (cs) in reply to Rick
Rick:
PiisAWheeL:
Bernard Kerckenaere:
That depends on the number of leapyears there's in those past 21 years.

I think I calculated for it. 21365.25246060*1000=662709600000

And your code will be long gone in 88 years when this fails.

Should've used 21365.24219878246060*1000 = 662695445466.43 (although the fact that it doesn't come out to be an integral number of ticks may introduce some error).

The length of a solar year is 365.24219878 days.

• Zunesis, In the Flesh! (Your mom's!) (unregistered) in reply to PiisAWheeL
PiisAWheeL:
As for the discordian calendar... I'm not sure if I love it or hate it.

Who the hell is St. Tib?

Hell, Saint Trib's the reason I signed up! Reason must folks sign up, I reckon.

• (cs) in reply to frits
frits:
boog:
...my client is an alcohol company, and I run their website. They have a members-only section of their site that requires that you to enter your birthdate.
Why? Is there porn there?
No, but there is violence. It's an alcohol company after all.
Violence is fine, as long as there are no curse words.
• Anonymous Coward (unregistered) in reply to PiisAWheeL

There is also the matter of leap seconds. There's been a few of those in the last 21 years.

• (cs) in reply to blueg3
blueg3:
Anketam:
Sad thing is in reality thanks to quantum computing our booleans might actually have more than 2 values. On, Off, Both, Neither.

More than four, but none of them are "neither".

For a one-qbit system, 0 and 1 are orthogonal basis vectors that form its state space. The qbit's state can be any unit vector in that state space.

An eight-qbit entangled system has 256 orthogonal basis vectors: |00000000>, |00000001>, ..., |11111111>. The eight-qbit system can occupy any state that is a unit vector in that 256-dimensional state space.

So.

It wont be a true boolean. Boolean by definition is true or false. What you (Anketam) describes a half or semi nibble. You have 4 different positions: on, off, FILE_NOT_FOUND, DATE_NOT_FOUND. (00,01,10,11)

Blueg3 you are just spouting nonsense. I'm not saying the theory isn't there... but how far into the future do you think its going to take before we have the technological capability to align those molecules AND be able to detect what position between 0 and 1 they are... What you basically have is an atom that can have a float value between 0 and 1... much like an xbox joystick. Functional, but not precise.

ps... i'm just trollin :p

• (cs) in reply to ShatteredArm
ShatteredArm:
Rick:
PiisAWheeL:
Bernard Kerckenaere:
That depends on the number of leapyears there's in those past 21 years.

I think I calculated for it. 21365.25246060*1000=662709600000

And your code will be long gone in 88 years when this fails.

Should've used 21365.24219878246060*1000 = 662695445466.43 (although the fact that it doesn't come out to be an integral number of ticks may introduce some error).

The length of a solar year is 365.24219878 days.

So I'm off by about 3.93 hours... my definition of a year is good enough for the government... who it matters too.

As for the next 88 years, I really wont care by that point and that will be the job security of whatever poor sap is trying to get the atoms on his quantum computer aligned right.

• (cs) in reply to PiisAWheeL
PiisAWheeL:
blueg3:
Anketam:
Sad thing is in reality thanks to quantum computing our booleans might actually have more than 2 values. On, Off, Both, Neither.

More than four, but none of them are "neither".

For a one-qbit system, 0 and 1 are orthogonal basis vectors that form its state space. The qbit's state can be any unit vector in that state space.

An eight-qbit entangled system has 256 orthogonal basis vectors: |00000000>, |00000001>, ..., |11111111>. The eight-qbit system can occupy any state that is a unit vector in that 256-dimensional state space.

So.

It wont be a true boolean. Boolean by definition is true or false. What you (Anketam) describes a half or semi nibble. You have 4 different positions: on, off, FILE_NOT_FOUND, DATE_NOT_FOUND. (00,01,10,11)

Blueg3 you are just spouting nonsense. I'm not saying the theory isn't there... but how far into the future do you think its going to take before we have the technological capability to align those molecules AND be able to detect what position between 0 and 1 they are... What you basically have is an atom that can have a float value between 0 and 1... much like an xbox joystick. Functional, but not precise.

ps... i'm just trollin :p

Yea... appears I misread the article I saw on the subject. Scary thing it does not look too far away.

• Carl (unregistered)

Now that we are on the verge of becoming a spacefaring civilization, it is long past time to discard our backwater planet-centric timekeeping system in favor of something Universal.

I propose a simple floating point counter of seconds since the big bang. Should work anywhere, forever. Leap second, leap year, Y2K, December 2012... who cares? Just keep incrementing that counter!

• Jim Howard (unregistered)

I don't write web applications, but what kind of toy languages are you web programmers using that don't have a proper time library?

Anyone who has thought about date/time computing for more than a picosecond realizes that date/time computing is a minefield best left to a library author who lives, eats, and breath time!!

• Sobi (unregistered) in reply to blueg3
blueg3:
Sobi:
Why should a year be the revolution time of the earth ?

Because that's the definition of a year. What you're proposing is to make something other than a year the unit for long-term time measurement.

The reason that's a bad idea is that proposals that confuse everyone except for incompetent computer programmers generally fail.

Oooh.

Now that you're spotting it, I do see a problem with my idea making things a bit confusing.

Maybe I should not keep the word "year" to name the new year concept... What do you think of nyear? It would be easy to understand (new year). But maybe the sound is too close. Nyur then? It's only four letters long and should be pretty easy to type on any mobile phone (well, it is on my Nokia 5110) which is very important since we want children to adopt it.

• Dave (unregistered) in reply to frits
frits:
This makes me wonder why the Euros are all pushing for a metric calendar. I mean the Leap Year problem is a pretty good example why the Gregorian Calendar should be considered harmful.

We must change the calendar because of stupid people. There's a new one...

CAPTCHA: mara - Hindu god of death; opposite of Kama. How fit.

• (cs) in reply to Sobi
Sobi:
blueg3:
Sobi:
Why should a year be the revolution time of the earth ?

Because that's the definition of a year. What you're proposing is to make something other than a year the unit for long-term time measurement.

The reason that's a bad idea is that proposals that confuse everyone except for incompetent computer programmers generally fail.

Oooh.

Now that you're spotting it, I do see a problem with my idea making things a bit confusing.

Maybe I should not keep the word "year" to name the new year concept... What do you think of nyear? It would be easy to understand (new year). But maybe the sound is too close. Nyur then? It's only four letters long and should be pretty easy to type on any mobile phone (well, it is on my Nokia 5110) which is very important since we want children to adopt it.

Who cares what you call it. Language tends to evolve to use shorter words anyways. You could call it a hoogawoogabooga and it would adventually get shortened to a wuga anyways.

• RandomUser423716 (unregistered) in reply to Anonymous Coward
Anonymous Coward:
There is also the matter of leap seconds. There's been a few of those in the last 21 years.
There we go! The obvious solution is to fix it with other leap units, like leap minutes and seconds.
• does some rough, probably-wrong math *

Let's just skip the last minute of every day (as currently defined), and fix the rest with an occasional leap second (back or forward, as appropriate).

• RandomUser423716 (unregistered) in reply to RandomUser423716

What that means the days for each month needs to be is left as an exercise for the reader.

• George (unregistered) in reply to PiisAWheeL

But that won't give you the desired answer. If it's your 21st birthday it will say you're too young for the first quarter or the day and old enough for the rest.

• (cs) in reply to George
George:
But that won't give you the desired answer. If it's your 21st birthday it will say you're too young for the first quarter or the day and old enough for the rest.
Article:
If you're less than 21 years old, they kick you out and won't let you onto the site until you come back on and lie about your date-of-birth
Not a perfect solution to the problem, but as you can see, it solves itself. My point is that it doesn't get hung up on leap anything :)

Possibly fixed with a round down on the date to the nearest midnight.

• (cs) in reply to szeryf
szeryf:
“There are only three hard things in Computer Science: cache invalidation, naming things, and handling of the 29th of February."
...and off-by-one errors.