- 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
But that's precisely why it's a problem! Right now + 86400 seconds is not guaranteed to equal tomorrow at the same time. If it's between 0:00 and 0:59 of the night in which the clocks will be set back by 1 hour, then now + 86400 seconds will still equal today.
Admin
...in your local timezone I wanted to add. Unless you keep everything in UTC.
Admin
ITT: People who never even tried to learn how to use PHP well insisting that it's not possible to use PHP well, much like someone who has never played the piano may conclude that nobody, anywhere, has ever played the piano.
Admin
Wait... management approved something eminently sensible and efficient? You lucky dog to be working there.
Now all ya gotta do is implement the same lockout for those leap-days and leap-seconds that have brought every known date-time software system to a grinding halt.
Admin
Queensland suffers from too many farmers and cows. The state needs more koalas and lungfish!
Admin
You are right. That's why I do everything in UTC until display. This is why you should NEVER do date calculations manually!
Admin
Because convenient assumptions about time are always wrong.
Admin
This:
PHP is definitely TRWTF.
Admin
Admin
DST adjustments occur at 02:00 local time and can therefore never cause the date to go backwards.
Admin
I didn't say the date would go backwards. I said 0:00 + 86400 seconds - 1h DST = still today.
Man, time math really does seem to be hard. Even the correctors correct incorrectly.
Admin
"incorrectors"
Admin
All programmers should know that knowledge of the past is very valuable. In the past previous programmers have done LOTS of work, and if you are any good, repeating said work will inevitably be wrong.
Moral of the story: Find the proper library and USE it!
Admin
In Java you have to write
Admin
I can comprehend someone thinking, "Maybe I'm the first person ever to want to create an ASP.NET GridView object with a column appended at run-time where the type of control for the column depends on the value in a table so each row can be a different control type" ... or something fairly weird like that. Or even if you're not the first person ever to want to do that, the requirement is detailed and odd enough that it's realistic to suppose that no one else has ever wanted to do EXACTLY that.
But, "Maybe I'm the first person in history ever to want to know what tomorrow's date will be"? Doesn't that just seem ... unlikely?
Admin
http://www.php.net/manual/en/datetime.add.php, you mindless numbskull. Just because you can't figure out how to write good PHP doesn't mean nobody else can.
Admin
This is yet another example of why we should:
(a) Eliminate daylight savings time (b) Eliminate leap years (c) Strangle the person who thought leap seconds were a good idea and throw his body to the zombies (d) Make all months the same length. I suggest 13 months of 28 days each. (e) Abolish hours, minutes, and seconds and instead divide the day into 100 centidays.
Think how much simpler all of our lives would be.
Admin
FTFY.
Admin
Just use .beats already or something.
Admin
The swatch beat is rubbish. It ought to be the length of a heartbeat if anything.
Admin
Fun times. Qld farmers and their cows have a lot to answer for - although I suppose we would have had similar issues irrespective of Daylight Savings if the Central and Western timezones had already been cut across....
Admin
Whenever I see such awful date handling code, part of me wonders if it's sheer incompetence or if it's designed to fail after a certain date, as a way of screwing things over after the person behind it leaves, while being ugly enough that the time bomb is not immediately obvious.
Admin
Sometimes you just forget and don't have access to the net. I don't know how many times that I have forgotten some basic function (i.e. String splitting in c++) and I am on the road without net access so you cobble together something with the full intention of replacing it with the proper function in the morning (5 years later it is still there looking horrible)
For me it is often less a symptom of being stupid as a symptom of switching languages too frequently. Personally I work with PHP, C++, Objective-C, Python, and Octave. I often have to look up the basics.
Admin
PHP 5.3 introduced some useful datetime constructs, DatePeriod seems appropriate in this case:
$start = new DateTime(); $end = new DateTime(); $end->modify('+1 month'); $interval = new DateInterval('P1D'); $dp = new DatePeriod($start, $interval, $end); foreach($dp as $date) { // do something }
Admin
Admin
Admin
Simple, daylight savings time.
Admin
The date function bundled with Ubuntu doesn't like this.
Admin
TRWTF is that someone considers himself a much better programmer and still reproduces the same RC problem as in the original code. The fix would be easy:
The RC is unlikely anyway? Exactly these kinds of RCs are the ones which will hit you in production when you least expect it. And because they are so seldom they hard to reproduce or to find through prior testing.
Admin
It's a heredoc:
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
Admin
Admin
Actually "heredoc syntax" - at least in PHP world. Also know as EOF notation.
Admin
TRWTF is DST and time zones.
In this age of global communication everyone should just use UTC.
Same with leap seconds, most people couldn't care less that whatever the current time is according to UTC is 35 seconds off from TAI.
Admin
In what holy book is it written that our calendar year must exactly match the length of time that it takes the Earth to make one revolution about the Sun?
If we abolished leap years, then yes, the date on which seasons start would change from year to year. So what? I think a simple, systematic calendar would have more benefits than a calendar in which the equinox always occurs on the same date. Which do you do more often: Think about how many days until your next payday, or think about how many days until the next vernal equinox?
Admin
Hmm, not clear why we need to create a new time zone for "internet time". Don't we already have UTC?
As to 1000 beats per day, okay, I'd rather call them millidays then beats, might as well stay consistent with the established metric system.
But yeah, I agree with the concept.
Admin
That's still super WTF-ery. It feels like order off of a menu.
"Hey, I have this date here, and can you super-size it? By how much? Oh yeah, 10 days."
Admin
But only about half of PHP sites are 5.3+
Admin
If we do not sync our calendar with some real world rhythm, it basically becomes entirely arbitrary and we don't need any "months" or anything of that sort and can indeed go straight to Swatch .beats or UNIX epoch timestamps. If months don't correspond to seasons at all, there's no real use for them. Right now months are useful to get a feeling for what the outside conditions will be at a given time. "Oh yeah, you don't want to do that in October, it's gonna be too cold outside for that." Without this correlation, months become entirely arbitrary and useless; just use powers of ten when you need "big time units".
If you don't have leap seconds, the clock will drift and diverge from the day/night cycle. So at 10am it could be entirely dark outside. So clock time becomes meaningless as well. Then we'll just go for a continuous counter like UNIX epoch time. "We'll have a meeting at 3728884822, okay?" You can get your pay checks every full fifty thousand seconds or so.
Does that sound like a more useful system? Time is complicated as it is because humans need it in humanly understandable units to be useful to them, and those units need to be synced to a natural rhythm, again to be useful. And unfortunately reality doesn't happen to be divisible by ten.
Admin
Yesterday I wanted to change a windows batch script to give a run duration. The search results seemed to indicate it doesn't have date functions either so I just echoed the start and end time and since all I need is a ballpark figure I calculated the duration in my head :P
Admin
In spring, is today's warm weather a signal or is it more likely a fluke? Calendars that made a year approximately equal to one revolution around the sun, with a month equal to one revolution of the moon around the earth, with leap months added to keep years roughly in sync with revolutions around the sun, did wonders in helping farmers guess the most likely answer.
Admin
In Python you have to write
Admin
Can I frame this and hang it on the wall?
Admin
Now I'm confused. Does this mean you are aware of your own limitations or you aren't aware of your own limitations?
Admin
You can know you don't know everything. Too many programmers think they have to solve every task with the things they already have in their head.
There are tasks like "My client wants to give 10% off, if they have 3 items, one of which is a coffee mug, on odd numbered Tuesdays" and there are tasks like "I need to add 1 day to today" or "I need to reformat yyyy-mm-dd into mm/dd/yyyy".
It bugs me that people so often fail to see the difference in those problems. One you're just going to have to attack all alone. The others are things that it must be true that tons of people are doing ALL THE TIME. If it SEEMS like there should be an easier way, there probably is. Surely no one can think that in order to get the next month of dates you have to make a SQL table, ask mysql to insert 32 dates (not in a loop), and then have some jumbled mess of a query ask for what you just explicitly inserted back.
As with any good TDWTF they even do it the stupid way the stupid way, but, again, I'll never understand how people don't get 70% of the way through a "solution" like this without realizing there MUST be a better way.