I’m pretty good with time zones. After all, I live in Germany, Hackaday’s server is in Los Angeles, and our writers are scattered all over the globe. I’m always translating one time into another, and practice makes (nearly) perfect. But still, it got me.
I was in the states visiting my parents, when Daylight Saving Time struck, but only in the USA. Now all my time conversions were off by an hour, and once I’d worked through the way the sun travels around the globe, I thought I had it made. And then my cell phone started reporting a time that was neither CEST nor EDT, but a third time zone that was an hour off. Apparently some cell towers don’t transmit time zone information, and my phone defaults to UTC. Who knew? For a short while, my phone lied to me, the microwave oven clock in the hotel lied to me, and I felt like I was going nuts.
But this all got me thinking about clocks and human time, and possibly the best advice I’ve ever heard for handling it in your own programs. Always keep time in something sensible like UNIX time – seconds elapsed since an epoch – because you don’t have to worry about anything more than adding one to a counter every second. When and if you need to convert to or from human times, you can write the function to do that simply enough, if you don’t already have a library function to do so.
Want to set an alarm for 2 hours from now? That’s easy, because you only need to add 7,200 seconds, and you don’t need to worry about 59 wrapping around to 0 or 23:59 to 0:00. Time math is easy in seconds. February 29th? That’s just another 86,400 seconds. It’s only us humans who make it complicated.
To get epoch (timestamp) in Linux from the command line or in a bash script
date +%s
To get time in many program languages see https://www.epochconverter.com/
Careful with Unix timestamps 🙂 We’re coming up on 2038!
And in 2024 handling daylight saving time (DST) is still an issue. Spent a good 4 hours this week debugging why a certain artifact storage system returns empty files. Turns out it had to do something with DST, because once the artifact was uploaded it could not be downloaded correctly for 1 hour, then magically it fixed itself.
It should simply be eliminated. We are no longer saving candle wax, it’s an absurd anachronism (pardon the pun)
Agreed. I like my midnight and midday to be at (or around) solar midnight and midday, dammit.
Having said that, imagine we kept to sundial time and having to calculate based on latitude as well as longitude.
Many people are for getting rid of daylight savings time. I’m for eliminating time zones and switching everyone globally to UTC.
Geting rid of daylight savings is fine, but putting the whole globe on UTC like it’s a submarine or a space station is just anti-human and weird.
Maybe it means every place has different schedules in paper. Some people will eat lunch when the clock shows 10 and others will do it at 22. Calling by phone someone else in your lunch time could mean they are angry because they were sleeping.
It already happens in Europe to a lesser degree. You do not need to change the clock when traveling between continental Spain and Norway by car. If you check the map in Wikipedia’s Timezone article, you will realise, end to end, they cover 4 time zones (-1 to +2), and going by “biggest land” then should be 2 consecutive zones (0 and +1).
That taught me that the issue ends being more that some places get “party animal” and others “hard worker” labels. Putting everyone in “UTC and just print different schedules for shops and everything” would show how silly the current situation is. Or make the jokes even more brutal: “Hobbits” eating 12 times a day to make sure they do not miss their lunch in the middle of the “night”.
Or as you say and the Wikipedia article suggests about how it works in China, authoritarian Kiwis will force their people to eat lunch in the middle of the night.
But you know what? Roosters do not care what the clock or paper schedule say.
It would take a while to get used to your noon locally being around 1400 or whatever it turned into, but otherwise it doesn’t actually make any difference. You work 9-5 now, you’ll work the same daylight hours but starting at 1500 and running into tomorrow on the calender days. Will have some weird effects on language for a while – is that normal daytime shift that now straddles 0000 the shift from the day you started or day you finished. But if everyone is doing the same things locally it won’t take long for some agreement on how to speak about it to form. And in doing so it then will clear up all the timezone crossing issues in our ever more global world.
Don’t really think its a problem myself – but I so rarely need to worry about timezones that the hassle of looking up the conversion between my local time and wherever isn’t that bad.
I had a Swatch .beat watch long time ago, that displayed the same time in beats for every wearer around the globe. Nice idea but it never really caught on.
+1
UTC 4 all
I can only imagine people in China suffering with a single time zone, some waking up to full sun other to a full moon. Not a chance!
If you’re US bound, whats wrong with WWV? They adjust for DST, you just need to know what time zone youre in, well there’s arizona……..
WWVB’s 60khz signal even indicates that DST is coming up days in advance so even if your “atomic clock” misses the transmission on the day of, it still should auto adjust.
I think UTC is good but even better then springing or falling a hour every 6 months, why not a worldwide change only 30 minutes one time. That would permanently adjust time to be closer to the daylight cycle more of the time than the spring forward/fall back nonsense. That way the shock of transition is eliminated. I know… getting the entire world to do this is very far reaching and a one time 30 minute fix would cause chaos.
Wouldn’t help the southern hemisphere !
There’s and xkcd for that :D
(2867 DateTime)
Gee, that made it so simple. NOT! When I go through time zones, I look for the “standard” clock, and then make my personal changes. For example, on a ship – “ship time.” If I know ahead of time, I just look at my cheat sheet. Add here, minus there. Nothing to get so worried about… there are some other real important things to worry about – sleeping, eating, working (for those that are), fun, and worrying time. Of all these things, worrying time is a very small thing out of a day, so I meter it out carefully. Good article though.
But how do you know when to get hungry or sleepy if you don’t know what time it is?
“Always keep time in something sensible like UNIX time – seconds elapsed since an epoch – because you don’t have to worry about anything more than adding one to a counter every second.” Still, at the end of the day except from the perspective of the clock no one adds seconds. Everyone looks at the clock. Of their choice.
I’d like to see days revolve around days. Make mid-day in the middle of the solar day, wherever you are. Make midnight the middle of the night. Alter work/ travel/ TV etc schedules to suit.
If we are biologically designed to function optimally on a circadian cycle (latin circa diem – around the day) why do we work 9 to 5 (3 hours before mid-day to 5 hours after) and are awake 7 to 11 (5 hours before mid-day to 11 hours after) (your hours may vary)?
because you have loose morals. Get up at 5 and sleep at 9 and everything makes more sense and you can look snobbily at people who don’t start working until 9am
“Get up at 5 and sleep at 9”
That’s called farming and your likely too tired to look snobbily except on days off (winter or very early spring after all crops dealt with and equipment repairs made unless you have animals then – never ;-)
Because there’s more to life than work?
Because then the train schedules would be all messed up.
When’s the train getting in? Hold, on, let me set up my astrolabe.
The whole time system needs a major over haul. Firstly, decimalise hours and minutes, then change months to 13 per year as they should be then back calculate weeks per month or just get rid of weeks altogether. Simples.
Maybe Hackerday could start using this sytem and see if it catches on?
We should start at beginning of next month.
It really doesn’t, you should be grateful the world agrees on a single time system at all.
It would be better if it did not.
someone tried that already…didn’t end well
France tried that, you can still find some clock dials around Paris that go to 10 instead of 12.
The inheritance of Babylon is strong, it will be tough to get the influence of base 60/360 degrees out of culture. Or seven day weeks (how did the Nordics get seven-day weeks? The names of days mostly come from Norse/Germanic mythos, yet how and when did the count of days travel there from the mid-east?).
Engineered culture or societies are usually dreck, only the naturally-emergent ones have any chance of staying around a while. Of course the French gave up metric time.
Rome had an 8-day week. Given everything else from Roman times that seems to have persisted to present day, why didn’t that one stick?
The length of hours changed according to season, that’s what happens when you use a sundial.
They say it’s also the reason why Italians are a bit more easy going about being early/late.
France pioneered the metric measurement system during the revolution and the idea spread to other neighboring countries. The same could be done with the units of time. Maybe France needs another revolution?
As a community of hackers, we could start producing DIY decimal clocks with 13 months per year and find a suitable decaying element to re-fix the duration of one second ….. but I sense an air of defeatism on these pages :(
Why 13? Lunar cycles? Then you’ve got a remainder so it’s not always right. How’s about no months and just days that increment for the full rotation around the sun, or maybe just increment indefinitely regardless. I’ll call it… Stardate.
NOT CORRECT!!!
Unix time follows leap seconds. So it might be 86399 or 8401 seconds. The only sensible thing is TAI (International Atomic Time). However, computers can not access it, as only UTC is broadcasted via network time. GPS time can be used to get TAI (fixed 19s offset), but that means the device needs a GPS receiver.
FWIW, it’s worth noting that PTP does provide TAI offset. And one can use https://data.iana.org/time-zones/tzdb/leapseconds instead of GPS.
“Want to set an alarm for 2 hours from now? That’s easy”
Yeah? Now try to set an alarm for 2:30 (AM) tomorrow. Oh, it so happens that tomorrow is the day that your timezone changes from DST to regular time, so there will be two occurrences of 2:30. Good luck!
Always store time in ISO8601 and use standard library calls to convert or do time math. (I think ISO 8601 has been superseded by a newer standard, but it’s backward compatible.)
+1
I prefer the tighter constraint of RFC-3339, which is a subset of ISO 8601. If it’s being communicated between computers, it should really be RFC-3339 compliant.
After I retired 15 years ago, I no longer change my wrist watches during Spring/Fall; At most, I’m within < 5% on a day basis and so far I can remember which season I am living in. I no longer worry about the date because I have to put on my prescription eyeglasses to get a clear view of the date number. One day I may not be able to remember the current season to perform mental arithmetic – but will exact time-of-day really matter then?
As far as setting an alarm to rise for an early doctor appointment, Alexa handles that perfectly. On other days, I wake when the cat insists on her breakfast food and I go to bed when I am tired. There is a sense of freedom not being a slave to a master clock.
As a young man, I was obsessed with the watches and clocks, using WWV or CHU to hack my Accutron or the mantle clock – multiple times a week, often daily with big ambient temperature swings. My two pendulum clocks would make me crazy if they did not chime in unison! I really wasted a lot of time trying to keep time devices accurate.
Getting older may not make one wiser, but it does make one less anal about precision.
> because you don’t have to worry about anything more than adding one to a counter every second.
Nobody tell him. Let him live in leap-second-free bliss.
About 20 years ago, I had one of the early “media PCs” running a version of Windows. It was supposed to record TV shows, like a VCR – but it crashed hard every six months.
Every time Daylight Savings started (or ended) it would stop trusting the time, and refused to record. Reloading the OS was extreme, but I never found an easier way to convince it to behave.
“running a version of Windows”
“it crashed hard every six months.”
Well….it was “windoze”….so working as intended :)
Dealing with 23 hours and 25 hours at work seems to cause problems every year that we have to resolve. The bean counters care as do our customers and generating facilities. It is a pain in the rear and costs money. All for moving to either Standard or Day Light. Just pick one. Time zones are ok. Easy(er) to deal with. UTC would be best of course, but humans would have a tough transition. A lot of people have a hard enough time dealing with a simple 24 hour clock…. Meet me at 14:00 hours…. or reading a clock with hands…. :rolleyes:
Anyone can read a clock with their hands, it’s the digital stuff that presents problems. Russian researchers did some research on that using blind subjects back during the Cold War.
Okay and now add to that that the United States goes to daylight savings time at a completely different point on the calendar than Europe so for a short amount of time it’s not 6 hours off of the East Coast but seven or five.,. And then I believe if it still hasn’t changed India is a half an hour different than everybody else…. I do like the UTC and our GMT because it makes things easy like plus one minus 5 except for… I know we’re at the minute Greenwich mean Time line is and I know what the time is where I live which is plus one GMT so I think we are in the same time zone. I am an acid daily reader of heck a day and I have some projects but at the moment I’m on medical leave and it’s temporary but I do not have one bit of spare funding available for the multiple Dev boards I would like use and I really need a Jetson Orian soc for one of my projects because it’s a trim down version of an open source llm combined with another open source llm combined with a convolutional neural network called sig53.. I’m doing all the training and additions to the knowledge base as well as converting my own data into the proper format be it a vector data base or sequel and that’s being done on for Towers they’re set up in a distributed fashion all of which contain various forms of Nvidia GPUs and AMD CPUs and as much RAM the second jam in there. They’re connected internally through a Enterprise level Cisco switch that I got out of the e-waste I also have several others I could swap out one is a Enterprise level Poe HP with fiber optic inputs and that also came out of E-Waste completely functional. I just snagged a machine that clearly was made to be a storage server or basically a network attached storage device in the form of a server and it contained a nick as well as a physical raid card with the ability to attach four drives to the array and those run at 7200 RPM. However because I have an overabundance of used hard drives because I’m a lawyer and I gave my word that I would do a complete and d o d / NSA level wipe of those drives. Or you could just use shred or a bash script that uses open SSL and a true random number generator. But the software that I’ve seen floating around also has some advantages as it hits part of the drives that even include bad sectors where those sectors could contain forensically retrievable data. But I’m having to try to complete a project which I gave myself a year to complete and there’s no way that I’m going to be able to finish it because my 3D printer head for the second time backed up and enshrouded the temperature probe on the Ender extruder and I’m sure everybody has had the same problem. My main machine is now AMD am5 form factor with Ryzen 9 7950x 128 GB of DDR5 RAM and it has the ability to take the 5th generation ssds but I opted for the 4th generation to terabyte ssds and in a very tricky marketing boy they have five slots on the board which I hope to use and it read 10 array along with a 4080 GPU but it lacks the pcie ability to post both 5 ssds in RAID 10 and the full power of the GPU! So if you can imagine which country I’m in where I’m finding it hard to consume enough calories per week while at the same time not being on social assistance whatsoever I’m actually funding my own medical leave! Pcbway did offer me a sponsorship which was nice I think that came from AI Williams as he referred to my project as way ahead of the curve, nice hustle, incredible specs well the problem is that I’m having a hard time funding those Incredibles! Your website and the content as well as the editing are fantastic and they give me enormous amount of rare but occasional happiness so thank you too all of you at Hackaday! I’m suffering from combat related severe complex post-traumatic stress disorder. I would wish this upon nobody and I’m on the list for compassionate use medication which is the only molecule to ever show any efficacy and the efficacy is quite High as the phase 3 clinical trial with published in nature medicine peer-reviewed journal and its field, June 2023. Because the challenge is related to my job I’ve added to the former eight years of University education an additional four so I now have 12 years of University and three different degrees. I started out and -5 GMT in my life and for the past 20 years I’ve lived in +1 GMT with a slight change where I was at research assistant +8 GMT. I also did my first degree and went back and took my first bar exam in -7 GMT. So I personally find GMT or UTC as they’re more or less the same to be my favorite version of a clock. That’s all exception is when as you say people twist and tweak the clock for various political or other reasons such as the difference between the changing of daylight savings time and the very odd half hour difference in one particular country. I kind of would like to have a more universal but not UTC but the universe actual space time as for me that would not only humble us as occupants of the only spaceship we have our Earth or our planet for the foreseeable future. And also gives a sort of connection to the bigger and yet vastly unexplored universe in which we reside. We have to remember that my first degree philosophy is still the only degree there is when you reach the highest level of education is that is the definition of PhD. And that everything that we talk about and deal with in this form and on these web pages owes it primary existence to the philosophers in mathematicians of old such as Euclid and physicist and theoretical physicists like Albert Einstein and Richard Feynman. Without the contributions of these mathematicians and theoretical and experimental physicist none of what we do would be possible! So a shout out to Einstein and what is really not time but SpaceTime!
Again a huge amount of gratitude and thanks for the authors and editors as well as everyone who contributes to the content that I read every day on this platform!
I’m sorry, could you repeat that?