- 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
Could be three. date()'s second argument defaults to time() if not explicited.
Admin
Admin
I agree with other commenters that there may be a reasonable explanation for this. The code may antedate the existence of the standard library functions, for example, or may be faster for common cases. Mathematica has extremely flexible date functions, but when speed matters, I roll my own. Since I know the input format that will be passed to the function, I can leave out the standard function's efforts to figure this out (is "11-01-1999" equal to 'November 1' or 'January 11'?), with the result being code that runs about 10x as quickly.
Admin
Wow, just wow... Be thankful he isn't a brain surgeon. No matter what the profession: pilot, doctor, engineer, accountant, lawyer, etc... you are expected to do research and some rereading of directions or instruction to stay good at what you do.
How one says RTFM requires more effort than coding your own implementation is beyond my comprehension, though.
Admin
Does no one here know about the DateTime class in PHP? Seriously? Its like this entire comment thread is 100% trolls :P
http://us2.php.net/manual/en/class.datetime.php
Admin
I blame Perl for being Perl. I blame PHP for being PHP. I blame awk for being awk.
I don't bother blaming idiots for using </insert language here>. I don't even bother blaming them for being idiots. That's cruel and unusual punishment.
I just laugh at their puny efforts and fire them.
Admin
And if you can guarantee that they'll all be called in the same second, that's a good idea. But you can't, so it's not.
Admin
Well after few years of praxis i can proudly say that for reimplementing such a common thing like date format function i surely dont have time..
But when i was little bit younger i nearly tried reimplement basic ops such as + - * / :)
Admin
Did you ever stop to realize that nowhere in the article it mentioned that the code in question was the root of all evil? No, the programmer was on vacation for some time, and then something broke. The sysadmin opened the code and found some reimplementation of a library function. Did that reimplemented piece stop working all of a sudden? Did the sysadmin change the code to a library function call, and everything was fixed right that instant?
Did you ever stop to realize that when I said "I submit the working code" I meant "After all documented processed have been followed, the code has been rolled out to production and has been working there for quite some time"?
Admin
The crap is that companies who insist on PHP as the progam "language" are sh*t. They don't want to or can't afford the money to pay for anything extensible. The same goes for MySQL.
So there. Hmph.
capptcha Syphilis::PHP
Admin
double Hmph.
How much can you "earn" coding in PHP and MySQL?
Moreover, how many crag replies will PHP/MySQL crappers respond to this? Har-de-har-har. Arses. Name any real companies use PHP. Name any real companies use MySQL. I Double-dare you. None. Because you'll be sticking your tongue on that nice, frosty, pole in the school yard.
Admin
And, yes, before you respond, a troll.
Only because I'm tired of hearing about WTFs that have to do with PHP or MySQL.
But I bet there will be people who can't resist saying how good PHP and/or MySQL is!!!
Admin
I've used bold to add my comments above, rather than enter and leave quote half a dozen times. (Yeah, I realize that the Javascript strftime library wasn't available for some time after the language was written - but it was fun to point out.)
I've fought attempts to do this every time I did a port with someone else. On at least one of those occasions, the person assisting me was supposedly an expert in the target language, there was a significant effort to do the literal port, and the other guy managed to fail in the effort - he introduced a slight semantic difference. Yet the single builtin routine that performed that function in the target language could handle either what the other guy implemented, or what he tried to implement. He claimed he was doing the literal port because he didn't want to risk introducing any change in behavior...
Admin
Mind reader eh? How could you know that getdate() returns current date/time?
Also seeing people giving date() as answer, we don't know what he did in getdate() so could he have gotten timestamp for date() easily or not.
This definetly isn't a WTF.
Admin
Since in only one of those variables one actually cared about seconds, I'd say I could, and it is.
Granted, it's three calls to the time function, instead of one in your example, but that's another thing altogether.
Admin
That statement is completely wrong in every sense of the word "refactor."
That defeats the entire point of "refactoring" because code that doesn't work is a bug. You don't refactor broken functionality, you fix it. Refactoring code implies that the code works but could be done better.
If code is written well, is easy to maintain, performs to expectations, then yes, don't refactor it. Just because it "works" doesn't mean it shouldn't be refactored.
Admin
(Of course, if you are doing significant processing between the two formattings then it's even more important, but that's less common with webpage processing than other programming tasks.)
Admin
Admin
See, that is the problem. You have to spend the time to determine whether it truly is working and truly is serving its intended purpose.
That's why I just decide to spend the time where I'm told to, like a good little boy, assuming the best in the middle of a massacre. "It's all OK. That code was strewn about for good reason." I move on, assume it works, and then assess what is my ASSIGNED task at hand, and remove all assumptions from THAT.
So many a dev falls in to the pit of despair, numbing one's brain across thousands of lines, only to be spit out of the corporate machine like a little pellet of bric-o-brac.
Whereas the dev who can maintain focus, will only have to deal with the reality before him... The ASSIGNED ticket. :P
Admin
"We actually have a very strict rule around here that forbids anyone from using standard library functions of any kind. It's just too risky."
You are kidding, right? :|
Admin
I wouldn't criticize this code until I've run it through performance metrics and consulted with the programmer on the intent (or consulted the design docs if any). Maybe two calls to date() are slower... maybe this function contains a work around for some obscure time/date localization issue... maybe it is a debug function accidentally left in...
Admin
Yes. I would also expect YogiBear to, as well: http://www.merriam-webster.com/dictionary/beg
If help's required, you're looking at number two under "beg the question."
Admin
A specialized and reliable jewelery manufacturer and wholesaler localed at China. We guarantee our company's Links of London jewelry, links london, links london jewelry, brace...
Admin
With high quality, good price, more than 3000 items, Charmtide is a leading suppliers of international luxury items. Located in Shenzhen, China, We are specialized in designing, ma...
Admin
He should have written: