4 ms·
My shop opens when the local clock tower says 9 am I want a cronjob set up to change the “closed” sigh to say “open”. How do I set that with UTC?
by midasuni 5y ago
My shop opens when the local clock tower says 9 am
I want a cronjob set up to change the “closed” sigh to say “open”.
How do I set that with UTC?
- noja 5y agoOpen your shop at 0900 UTC
- PetahNZ 5y agoSet the cron job to run every hour in UTC, and your application logic checks if its time to open in the configured time zone.
- kymaz 5y agoSo the fix to using UTC for computers and crons that only care about the local time zone is to reimplement time checking? If youre just gonna run it every hour, you might as well while(1){ check time; do stuff; sleep 1 hour;} now there's one less dependency?
- dbaupp 5y agoUnfortunately there’s more … interesting time zones than UTC+/-xx:00, and more interesting transitions than moving an hour. For instance, Nepal uses UTC+05:45, and the time shifted by 15 minutes in 1986 (from UTC+05:30): https://www.timeanddate.com/time/zone/nepal/kathmandu https://www.timeanddate.com/time/zone/nepal/kathmandu That said, I think running every 15 minutes handles all currently-observed time zones.
- dqv 5y agoYou store the time you want to see on the clock tower and the timezone where the clock tower is. Every hour you do the following pseudocode: if utc_now().to_timzone(my_timezone) >= "9AM": sign = "open" I know you didn't mean this, but it was a problem I thought about: How does one make sure the local clock tower actually changes in cadence with DST? You can't, so I guess you could use open vz with a camera to have your open sign be based on what time is actually seen on the tower. I know it's just an example, but I say in jest, don't use cron jobs to change your closed sign to open! If you can't make it to your shop, people will be waiting around all day for you to unlock the door. Very unhappy customers.
- remram 5y agoThis is just duplicating the code already in cron. Of course you can make cron simpler by running your script every hour, and making the script more complex. You're just pushing the complexity to user-authored, non-reviewed, non-tested code. What is the advantage?
- dqv 5y agoThe first advantage is that you can dynamically check what your actual open hours are rather than having them statically configured (e.g. a web service to check for holidays). Open hours are never actually static. (Unless maybe cron does holidays?) The second advantage is that you can check in multiple timezones especially if the server itself is in DST. Does cron itself let you set the timezone for each individual check? Or does it only run in one timezone? As far as I can tell, it only lets you use one timezone.
- remram 5y agoYou can still run whatever business logic from cron to decide whether you took the day off or you have the resources to open. Offloading the timezone logic to cron still makes sense, since running tasks at the right time is exactly what it's for.
- 5y ago
- dzdt 5y agoThis is a same problem in financial markets. Things like options contracts depend on a value observed say at 10am New York time on a particular date a decade in the future. If the daylight savings time schedule changes between now and then then the UTC time of the expiry of the options contract will change. The right reference isnt UTC or EST or EDT but "NY City local time" (or Tokyo or Warsaw or Mexico City or whatever is the relevant jurisidiction).
- oxfeed65261 5y agoFirst of all, you’ll need a webcam pointed at the local clock tower…