- 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
Mandatory asinine initial comment.
Admin
please switch to Kiev
Admin
Obligatory implication that such code is a result of being written in PHP.
Admin
I live a few miles north of Greenwich, pretty much dead on the prime meridian. I found a bug in some GPS software once, because my longitude was something like 0.00000001 and some default string formatting routine rendered that as 1E-8, and then a different parsing routine later failed to parse it back in properly.
Admin
Danger! Don't go down this route of timezone WTFs. There is enough timezone WTFery in the world to generate material for the daily WTF until the Sun becomes a white dwarf star. The trouble is, it's banal. It's at the heart of the banality of WTF (sorry Hannah Arendt).
That being said, Halifax as the location of the principal meridian? Why not?
Admin
Don't we know it... not just time zones but time in general is a major source of contributions around here.
That said, if you're running on a distributed system and your backend server is in a particular location, why not sync everything to that location's time zone? Makes data analysis a bit easier.
Admin
Interestingly, PHP's increment operator works on floats! It is very C-like in this regard.
Admin
Why should Halifax in America be the centre of the world? Obviously it should be Halifax in the UK!
Admin
The only true time is number of microseconds since Unix was written, which is timezone independent.
Admin
As someone who lives in a country with a single timezone with no daylight savings, I also used to think like you many years ago, but ask yourself a couple of questions in regards to your proposed approach.
What if that server's location's timezone has daylight savings, when you record the times in the database, are you persisting daylight savings or non-daylight savings time? If that records an event added at 2:30am on the a day that it is moving out of daylight savings, what time is that relative to other time zones?
For that second question, it's actually impossible to be sure, 2:30am is ambiguous as it happens twice on that day, which is why every decent software language these days has an API for trivially handling conversions of times and dates to and from UTC taking into account things like daylight savings, with the idea being that you always persist your data as UTC, then convert it coming out as needed.
While one might argue that at the end of the day UTC is an arbitrarily chosen reference point for all other times, and you could in theory choose some other timezone time (which doesn't suffer daylight savings), the fact is that UTC is the reference point which pretty much all software knows how to work against.
Even JavaScript plays nicely with UTC with no libraries installed, type the following in your browsers console (F12 in Chrome)
new Date("2000-01-01 00:00:00Z")
and press enter. Unless your computer has it's timezone configured to GMT, you will notice it has changed the time to your local time.Admin
I was going to remark "wrong Halifax", but I see P's already been to Ilkla Moor baht 'at.
So I'll just note that Cornify is back, but I haven't seen any rainbows yet, only rainbow-coloured unicorns (and grey and golden ones).
Admin
The real WTF is that you usually have no way to suppress recalculation to UTC - I can see why such code get requested in first place. In my experience I have more often need to store and calculate time without any timezone than with it. In distributed environments it can be hard to get current "clock on the wall" time at location.
Admin
Because, whenever you create a new particular standard (as in, it is particular because you don't dominate the industry and can't make everyone else use it), you end up having to support the standards you had before AND the new one.
You'll eventually have to take input from from sources that do not follow your standard (it could even be people from inside your company that are used to the older standard), and then you get the wonderful experience of finding out a bit too late that you saved a lot of data in your DB that do not conform to your standards and it's now impossible to separate the tainted and "pure" data. Or you'll have to be on your guard for all eternity double checking every input if it is conforming to your standard.
When two differing standards clash, you might end up with a Mars Orbiter disaster.
Admin
Damn I was supposedly replying to Brian's question
Admin
In my country time moves forward at 1:00am to 2:00am and backwards from 2:00am to 1:00am. So 01:30 am will occur twice when moving back.
Admin
Also, leaving time in UTC allows you to move servers between time zones (or have multiple, redundant servers in different locales) without having to guess what the time represents.
Admin
Unfortunately Unix time ain't that. It's both defined in terms of a specific time zone (UTC) and takes into account leap seconds. As such Unix time is not an actual count of elapsed seconds since the epoch.
Admin
That seems like way way to much work to do something that should be as simple as adding/subtracting a few hours to a datetime.
Admin
Don't blame PHP for this developer being brain dead, they released improved DateTime functionality in 2006 with PHP 5.2.
it's the "//end if" that really makes the code, though
Admin
He's also overlooked a small point: there isn't just one Halifax in "America". If we (incorrectly) take "America" in time zone strings to mean "the USA", the there are seven, but the best-known Halifax in (North) America is Halifax, Nova Scotia, which is in Canada.
These eight different Halifaxes aren't all in the same time zone.
Admin
Well, America/Halifax is a very specific time zone though: https://timezonedb.com/time-zones/America/Halifax
Admin
Sure, which is why I was careful about what I wrote. It's still ambiguous. ("America/Canada/Halifax" would be less problematic, except for questions of ... politics, because for at least some other instances of three levels, "America/X/Y", the middle part ("X") is a US state.)(1)
(1) Which inspires memories of my 11th grade Social Studies teacher (in Endicott, NY), who poked fun at ethnocentrism by advocating, based on a series of economic, political, and defence-oriented benefits, unifying all of North America into a single country...
... and that it should be called Canada. The surprised outrage from the other students was clearly audible. Being not from either of the countries in question, I laughed quietly to myself.
Admin
You're just trolling. In PHP, America/Halifax is unambiguous. It refers to a specific timezone. To call it ambiguous is like calling the color green ambiguous because color-blind people won't know the difference.
Admin
If you don't know the reference of the title of this post, Google "Happy in Paraguay" and watch the video.
Admin
Fine by me. I'm sitting next to Halifax Harbour right now.
Admin
Halifax in Nova Scotia. It'd be a true WTF if it was Halifax, West Yorkshire.
Admin
for some reason an old "Tintin" comic strip comes to mind: apparently French ships used to use Paris as zero on their maps, which complicated a treasure hunt Tintin and his friends were on... also, there was a Darwin Award story where a group of terrorists were killed by their own bomb, apparently because of confusion over Daylight Savings time. oh yeah, and an old adventure game used "halifax" as a password to open a treasure chamber!
Admin
Everyone used to use their own meridian, the French/Belgians would have used the Paris Meridian, and maps weren't updated as frequently back then ;)
Admin
The International Space Station begs to differ.
Admin
And why are Halifax residents called "Haligonians"? And precisely when is the Last Tango in Halifax (vs. Greenwich)?
Admin
From Hell, Hull, or Halifax....
Admin
But everybody knows the centre of the universe is Huddersfield ;-)
Admin
Timezonez!
I recall that someone in the operations department told me that we used to run one windows server in Asia/Baghdad time (physically in America/Chicago) so that the data consumed in the data centre in Europe/London (UTC) would be happy. Simply because the software running was modifiable and the resultant localtime changes between the data received (EDT) and what was required (UTC) cancelled out.
Admin
Weel, There is "Meantime Brewing Company" in Greenwich which has some rather nice beers.. I have no knowledge of such a place [does not be it is not there] in any of the Halifax's I am aware of ;)
Admin
Timezones are just plain weird. Nicely though one of games I play has a new "daily challenge" that pops up every day at midnight "local time". For us in the USA that puts us at a strategic disadvantage as we are the last to have the end of the day, and the beginning. All is not lost since Apia (in Samoa) is nicely on the other side of the date line and only a couple of hours ahead. A simple set of the time zone allows one to jump ahead a day.
Oh, it hasn't helped me get a higher ranking score. Oh, well.
Admin
Ten bucks and a fig newton says this was the result of a clueless manager demanding that the time be set 'properly' rather than using weird 'foreign time'.
Admin
Greenwich has the distinction of being where John Flamsteed punched out Isaac Newton.
Admin
The only true time is number of microseconds since Unix was written, which is timezone independent.
The International Space Station begs to differ.
Ok -- does it differ about being TZ_independent, or just about the number of elapsed microseconds up there as opposed to down here? Or both?
Admin
Remember, Unix time sweeps leap seconds under the carpet. As a consequence of that, the ones digit (in base ten) of Unix time is always the same as the ones digit of the seconds in UTC. Except maybe during a leap second. I'm not sure Unix time is even defined during a leap second.
Admin
Ever see this at the end of a code block: } } } } } ... and wish you knew which } is which?
:) Just sayin'
Admin
Leap seconds are treated like an error. The local clock is simply instantaneously found to be a second out with a high-quality time source, and NTP will resynchronize that sort of thing easily.
Admin
@eric bloedow: They did, and you can still see where it ran. A couple of decades ago they mounted a number of medallions in the pavement all down France to mark its anniversary or something like that. I've stood on both meridians.
Admin
@Steve_the_Cynic: still all eight the wrong Halifax, though.
Admin
or better yet...Halifax in Canada...
Admin
It differs because it has its own time; per relativity, there is no "true" flow of time.
Admin
Not sure what floats are involved in this snippet but PHP increment operator works on everything (as long as you're flexible with the definition of "to work"). It's the Chuck Norris of operators.
foreach ([7, 7.1, 'a', 'ZZ', new DateTime('2017-01-12 00:00:00 UTC'), fopen(FILE, 'r')] as $value) { $x = $value; var_dump($value, ++$value); }
int(7) int(8) float(7.1) float(8.1) string(1) "a" string(1) "b" string(2) "ZZ" string(3) "AAA" object(DateTime)#1 (3) { ["date"]=> string(26) "2017-01-12 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#1 (3) { ["date"]=> string(26) "2017-01-12 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } resource(5) of type (stream) resource(5) of type (stream)
Admin
apparently apple's weather app is based in pdt, as it displays yesterday's weather for 3 hours;-\
Admin
apparently apple's weather app is based in pst, as it displays yesterday's weather from 12-3am est
Admin
Actually, amazingly, this makes sense. No doubt it's completely obsolete now but there was an arcane truth about Halifax, Missouri. Because it was near the center of the continental United States, it used to be where AT&T's Master Clock for their entire phone system was located. Can't find that on the web now, something I read about years ago.
Addendum 2018-01-13 09:17: I wonder where our Master Clock is now?
Addendum 2018-01-13 09:31: Found it. And it's a false memory. Hillsboro, Missouri.
https://books.google.com/books?id=pcVsK0mWULwC&pg=RA1-PA44&lpg=RA1-PA44&dq=at%26t+master+clock+location+missouri&source=bl&ots=QRsh10yp17&sig=R7InGVUUaeRXplegUp2Bt_lAr80&hl=en&sa=X&ved=2ahUKEwjw6tWek9XYAhWMON8KHUbvBIE4ChDoATABegQIFBAB#v=onepage&q=at%26t%20master%20clock%20location%20missouri&f=false
Admin
Dayjob Orchestra is the real WTF! https://www.youtube.com/watch?v=414TmP12WAU