- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Fri.
Admin
How much do you want to bet that the schmuck who wrote this was told "just do something quick and dirty,the new system is rolling out in a few months"?
Admin
Yes. Why use perfectly fine, and well tested, date libraries when you can just write your own WTFy code? Where would be the fun in that?
Admin
If this was done in the 2000s, then the software laster longer than most of the 1980-199x software that caused the Y2K mess in the first place...
Admin
It's a problem just 1% of the time. Not worth fixing.
Admin
Just change it to:
year = year.replace('20', '', 1)
So it will only replace the first occurence.
Admin
Duh! Use regular expressions, obviously: replace 20(\d\d) with $1
Admin
Of course just doing a substr would have been simpler, more efficient and not have broken (until 10001AD)
Admin
Substrings are the answer! year=year[-2:]
Admin
Clearly a competent programmer would have connected to an SQL server and used the MOD() function there. (Environments like Java and .NET don't have a MOD() function and are therefore inferior.)
Admin
Up here in Norwaystan, people who are 105 this year have had their parents (!) called in to parent-teacher meetings in preparations for their first school year. Did they learn nothing from Y2K?
Admin
year = timezone.now().year % 2000;
nuf said...
Admin
And this will misteriously stop working in 2100th.
Admin
Once the calendar year rollover bugs are through, it will just be time for fiscal year rollover bugs...
Admin
Right. Who in their clear mind would think a percent sign could be used for anything but for "percent", especially in an enterprisey environment?
And while we're at it: we must make sure we access a server which is available. If the first one fails, load a list with possible sources, and search every single one of them in turn, and let it evaluate its MOD() function.
Admin
Oh, and .NET DOES have a MOD operator. Just not in the most used language C#, but in the clearly superior VB.NET. After all, it uses more human readable words, so it must be better.
Admin
"In a few months"? That lucky fellow! Usually, it's more like "next week" or "tomorrow".
Admin
And in some not-so-rare cases, "today".
Admin
If this is the only problem with a system that only has 2 digits for year, then the system must be a true masterpiece created by a true genious.
Admin
Oh come now, clearly everyone knows the answer to this problem is a switch/case statement.
Admin
The sales department promised a delivery date that was three days ago. Get to work.
Admin
It still doesn't accept the correct syntax of MOD(x, y) though. Damned modern languages.
Admin
"oh, I know it's a hack, but it's too late and I'll have 19 years to fix it. Probably will be done properly by next week..."
Admin
Oh that was a good one. This is the kind of black hole in thinking that goes on in the mind of your typical stringly-math idiot. I actually laughed out loud.
Admin
Fortran uses % as field access operator.
Admin
We will face similar issues from now on every new decade: For many systems, the Y2K bug was "solved" not by making the 'year' field 4 digits long but by introducing the concept of "windowing", where (for example) any 2-digit years less than '20 are considered to be in the 2000s and any 2-digit years bigger or equal than '20 are considered to be in the 1900s.
Similar problems will occur in 2030, 2040, 2050, 2060 and 2070.
Admin
We will face similar issues from now on every new decade: For many systems, the Y2K bug was "solved" not by making the 'year' field 4 digits long but by introducing the concept of "windowing", where (for example) any 2-digit years less than '20 are considered to be in the 2000s and any 2-digit years bigger or equal than '20 are considered to be in the 1900s.
Similar problems will occur in 2030, 2040, 2050, 2060 and 2070.
Admin
Why "timezone.now().year % 2000;"?!?
If you want 2 digits, it's %100.
Admin
Is it time to stop congratulating everyone on their efforts with Y2K?
Admin
I worked on a system in 1999 that stored years as single digits. It previously stored them as 2 digits but someone decided to repurpose the first digit as a status code instead of adding a field to the table. Thus our Y2K remediation more comical than most.
Admin
Just be sure to build a table with all of the years 1900 to 2100 and their allowable two digit version. Problem solved.
Admin
I'm glad I learned through my own mistakes to never put a temporary system in place while working on a permanent one.
Pretty sure one of the "temporary" solutions I made is still running a website backend 22 years after I wrote it.
Admin
Right, "%" just won't do. Needs to have function semantics.
Admin
brilliant. why take the last two digits, when you want to get the last two digits, when instead you can remove an arbitrary string from everywhere in the input?
brilliant.
Admin
I assume that it will be a major operation fraught with borkage if you try to change the year field from two digits to four digits.
Admin
"Who in their clear mind would think a percent sign could be used for anything but for "percent", especially in an enterprisey environment?"
But of course, the percent sign means "percent". Let's try it:
25% 4 == 1
50% 4 == 2
75% 20 == 15
etc.
Admin
Temporary systems are longer-lived than permanent ones. E. g. the Federal Republic of Germany was constituted as a temporary solution until Germany's reunification, and the German Democratic Republic as a permanent one (as a part of the ever-lasting communist block). And which one of them survived to this day?
Admin
Admin
Good news is that this bug will go away on the next new year. No need to fix it, it will fix itself
Admin
If you must window, make the window relative to the current year.
And manipulating numeric data - which dates are - as strings is just plain stupid.
Admin
Work with legacy systems that do both 2-digit and 4-digit years. Not sure what the trigger is for 2-digit logic, but it causes severe problems. We have a T.S.R. program that lets you configure the roll-over year; so if it's set to "15", then it goes 2014, 2015, 1916, and on and on. The legacy system is launched by a lot of different people, so we have to update the BAT files to change the call to the T.S.R., network-wide. Fun times.
Another beauty is a web-app that was contracted out. End result from user entry is data with dates like 01/19/0020.
Admin
The code is perfect. Will fix itself after a year. I don't see a need to spend time fixing it. Just mark it as won't fix.
Admin
If I was going to solve this by "mangling a string" I would use a substring operation (take the last two characters/remove the first two characters), not by doing whatever nonsense that was.
Admin
Want to have a laugh? Search an existing large code base at the company you work for the following strings, which might appear in code comments: “Temporary” “To fix, or “to be fixed,” or just “fix.” “Kludge” ”Hack”
Admin
TRWTF is using string replacement instead of substrings - seriously, just remove first two characters from the year and it will work always, until we get to the year 10000, at which point no one will care.