- 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
So the WTF is that the developer though that you can't use Unix Epoch on a windows server?
Also Frist
Admin
scond
not spam
Admin
This aproach is prefered. Simpler to be converting to C for linux app (much quiker performing) or any system without suport library function. Time function is wel-defined already: why convert to langage-specific fuctions for no benefit?
Admin
It doesn't account for leap years correctly...
Admin
It does account for leap years: (((year - 1970)/4) * DAY)
But because 2000 is not a leap year the generated date is one day off. As long as both dates are between 1.1.2001 and 31.12.2099 no one will notice.
Admin
This comment was designed to be Frist.
Admin
The gobble about UNIX epochs being a bad fit on a Windows server is just so much gobble, possibly because of bad anonymisation.
Admin
Bzzzt. Thanks for playing.
Admin
You got me. 2000 is dividable by 100 and 400.
Admin
Admin
Admin
"If it ain't broke, don't fix it" So much for Code Excellence!
Admin
So it's OK to be wrong, as long as you're consistently wrong, except when you're not, except when you might be, except when you're really really wrong (then classify it as a feature request).
Admin
((2000 - 1970)/4) = 7.5, no?
Admin
Yes, they didn't want to use the built in C# libraries, which handle dates past 2039 (Epoch seconds overflow a 32 bit integer).
Admin
The Y2.1K problem in the making.
Admin
Apart from all other things - did anyone notice that the DAY multiplication could be put outside the brackets?
Not to mention that the /4 division could have been handled through bit shift;)
Admin
Anyone notice the last bracket is not matched?
Admin
(2000 - 1970) / 4 = 7
year is an integer.
Admin
"Not to mention that the /4 division could have been handled through bit shift;) "
I see the smiley, but really, let's code what we intend to do, not how to do it.
Admin
I DESPISE that quote and the associated mentality with the fire of a thousand suns. Something can be "broke" and still appear to be working properly; doesn't mean it isn't broken and should be ignored.
This mentality is the reason there is so much shitty software out there (and the reason this site exists) because people are so reluctant to mercilessly refactor code and follow good craftsmanship principles under this false pretense.
The greatest lie in business is "The customer is always right". The second is "If it ain't broke, don't fix it".
Admin
Your comment does not function as it was designed. I will submit a bug report.
Admin
Wow, that's ingenious! Now just to convert those weird two-byte characters into proper 1-byte ASCII characters that don't waste memory like crazy!
Admin
Also, if you omit "frist", I nominate ur post for featured coment.
Admin
WTF? There is no reason whatsoever to "optimize" for other platforms just because you might port the application sometime in the future. Using language specific functions when you can saves code, maintenance and usually gives you less potential bugs to worry about.
Admin
Sure, let's make something that will break on January 19, 2038. http://en.wikipedia.org/wiki/Year_2038_problem
Admin
TRWTF is
.Admin
[quote user="ObiWayneKenobi"][quote user="ParkinT"]"If it ain't broke, don't fix it" So much for Code Excellence![/quote]
Agreed. I just finished a product that was so focused on the front end working that several key backend processes were forgotten all together. But, hey, the front end was pretty and worked "right".
Admin
(Read about Hungarian notation some time. The original intent was that it would show stuff about the content of a variable that could not be captured in its type, such as that a "char *" points to a string rather than a single character, or that that string is zero-terminated, or more usefully that it is or is not XML-escaped or some such. So char *sMessageText is points to a string containing the raw message text, and char *xsMessageText points to the XML-safe version.)
Admin
The story omits the rather important detail of what information Jeff included in his bug report.
If it was "it should use built-in date handling code rather than use a custom library based on Unix epoch," I can't fault the team for reclassifying it as a feature request.
If he submitted two or three examples of dates that this code got wrong, then it's clearly wrong to treat it as anything but a bug.
Admin
So what do we have:
YEAR = 52*WEEKS (not used in this snippet, though) 1972, 1976, 1980 and so on are not handled as leap years 1974, 1978, 1982 and so on ARE handled as leap years Input year is never handled as a leap year
Admin
Also, lern to use "quote" buton.
Admin
...or leap seconds
Admin
If it ain't broke, you reviewed it wrong.
Admin
You do integer division much?
Admin
Feke haker Nagesh is ruining my good name!
Admin
Your bug report has been downgraded to a "feature enhancement request". Rationale: The comment does function as designed, which is to provide a commentary on the article. Desired ranking of Frist is noted, and will be slated for a future upgrade.
Admin
Admin
Admin
Thank you for your input. Your cheque is in the post. (In case you don't understand English, that means: your check is in the mail.)
Admin
Admin
Implicit conversion from floating point to integer always just truncates, cuts off anything after the decimal point. There's no automatic rounding off, and that's why there are usually some standard library functions like round() and ceil() to make explicit which rule to follow. (int) 7.99 = 7 (int) -3.99 = -3
Admin
Admin
Here in Hyderabad, explaination of integer rounding in CS is first computer coarse that freshman take.
Admin
Please tell me you're trolling and not really that stupid! This is truncation, not rounding.
Admin
TRWTF is the ridiculous formatting. Why Must every thing get its own line
Admin
No they don't. Example:
-9 / 2 = -4.5 truncates to -4 (i.e. towards +Inf, not -Inf)
And Banker's rounding is TRWTF!
Admin
We don't all have fancy wide- screen monitors you insensitive clod!
Admin
Admin
TRWTF is "to the bug-fix queue for the offshore team"