Timezones are the bane of my existance. Whenever I join a project, it's right about the time that they're doing something that has to deal with timezones. But only sometimes. But definitely has to deal with someone in a plane changing timezones. During the DST switch. ARGHHHH
I get get shit from some coworkers because I log everything in UTC, literally every date is in UTC, however I also use DateTimeOffset fields to store them so it’s actually rather easy to convert they just think it’s a hassle. I mean do we really need to know when something fucking happened in a mission critical system with data centers in 4 time zones, some of the legacy apps use sys date for the db server and that’s set to the time zone but there is no offset attached so when the reports are run on the aggregated tables in the report server the date times mean nothing at all. Auditing that app is a bitch, but I’m not the DB guy so I don’t know what I’m talking about.
Oh, absolutely. Log everything in utc. Store dates in UTC if possible. If you can, take api input in utc. That's not always possible when getting input from a variety of devices. Then there's the UX of various sorts. Used to work on fitness tracking software... What does a sleep look like when DST changes in the middle of the night? How do daily tallies (for things like steps) look in a 23 or 25 hour day? What's a day when someone changes timezones? If the user has a reminder to stop having caffeine at a certain time of day (to get sleep), well that should probably stay at the same time of they change timezones, right? But what about a medication reminder? If they have to take it every 8 hours, you don't want that to follow timezone cuz you'll end up with one interval that's too long, and one that's too short.
Oh, there is one exception: if you work with dates (dates. Containing no time part) that have symbolic value, it should be stored as 20200624 (yyyyMMdd). Never add timezone information. Like a birthday. It does not start at 00:00 German time. When I live in Australia it starts at 00:00 Australian time. When birthday is in DST period, and we have December, ans I look at the calendar, it shouldn’t display it as starting at 01:00 in the morning and ending the next day.
To summarize: for those, who understood how time and time zones work and the implications they have, will always store points in time with time zones. They will do it automatically there is no other option
After that, we should always understand that durations are commonly stored in some datetime typed field. But durations just don’t have timezone. A duration is a duration. A duration of 2 hours, 58 minutes must not converted to some timezone first before being applied to something. It is 2:58 in Australia, it is 2:58 in Europe, it is 2:58 all other areas.
Now back to birthday and other dates. It is not a time range having a starting and ending point. It is by itself a point in time. A large one, but it is a point in time. It has a cake but no timezone. It receives the timezone from the user that looks at it. From users place and time.
Oh, and the ux that displays your logs might want to (at least give the option to) convert it to local time. Way easier to diagnose stuff if its easy to figure out that it happened "2.5 hours ago" or "15 min ago" without having to constantly do mental gymnastics.
The client wants all dates and times in Eastern TZ, So that’s what they get, but in the data it’s all stored as UTC. They have users all over the US, Alaska and Hawaii to Florida and Maine.
The other systems i interface with have problems telling someone just exactly when something happened. Unless it’s a request from my system as I just find the transaction and use my sent to them and received from them log times. But if you are tracking a web initiated external request have fun with the inconsistencies in the dates and times.
But what if OP and their sister were born in a country that was using the Julian Calendar back then, but has since switched to Gregorian? Also they were born in different time zones, one of which no longer exists. And his sister was part of the population snapped away by Thanos, so she lost some 5 years, give or take.
I am just discovering this. I have a hobby project to learn from, and it involves a set of graphs with data from one single api. They are all correct, except this one bar graph where the dates are off by 1. For the life of me I can't figure out what the hell is going on. It's probably a conversion from a timestamp to a date but all the other graphs are fine!? I seriously added a title to the graph that says "dates are 1 day behind" so you see that on hover over.
59
u/LiqdPT May 16 '20
Timezones are the bane of my existance. Whenever I join a project, it's right about the time that they're doing something that has to deal with timezones. But only sometimes. But definitely has to deal with someone in a plane changing timezones. During the DST switch. ARGHHHH