Live data from Hacker News

British Columbia, Time Zones, and Postgres

crunchydata.com

61–70 of 117 posts

Re: British Columbia, Time Zones, and Postgres

#61
post #10

This strategy fails for appointments during that hour where the clock goes back: they are ambiguous, can refer to two different moments in time. That caveat aside: good.

I have yet to find a technological solution to this social problem. Also, I have yet to encounter this problem. For personal events, I sleep during this time. For company events, we always avoid this time.

I have, in the context of time series charts. Lots of back and forth with QA.

Re: British Columbia, Time Zones, and Postgres

#62
post #34

Earlier quoted context omitted.

It‘s a common mistake to store everything as UTC timestamps and shows lack of understanding of time domain. Local time exists and it is neither UTC or timezone-dependent. Doctor office opens at 8 a.m. regardless of whether it is DST or not. Appointments are made in local time. Store them in local time.

> Appointments are made in local time. Store them in local time. You may just be illustrating a particular use case, but it is more ambiguous in the general case. For example if you have arranged a meeting with someone in another timezone then maintaing the local timezone could lead to a misalignment for one of the participants.

This is ok. When future local user time offset is unpredictable, pinning meeting time to a certain location is a good strategy. If at some point meeting shifts for some user, well-designed calendar app could warn them and let reschedule. It still works better than pure UTC because it is predictable for at least some of the users.

Re: British Columbia, Time Zones, and Postgres

#63
post #47

Earlier quoted context omitted.

No the OP, but I'm also in BC and dislike this change. The change was made (partly) based on a bullshit poll of residents, that asked basically "Hey which would you rather do, use year-round Daylight Savings Time or keep switching every six months?" - notably not including the option a lot of people wanted (and which is well-supported by a lot of research as the best option), which was "use year-round Standard Time".…

If we did that the sun would be coming up at 4am right now in Revelstoke. What's the point of the sun being up at 4am? On the other hand, I don't like it getting dark at 3:30 in the afternoon in Vancouver around Christmas. I know it means it will be darker later in the morning but you wake up in the dark that time of year already anyways.

Go for a run, hit the ski hill, all before you start work. The sun runs your health (circadian rhythm). I'm in Vancouver and this is the dumbest change. We're going to pay for this for a decade in premature deaths, and we'll end up on standard time anyway.

Re: British Columbia, Time Zones, and Postgres

#64

Future events: store the local (at the event) date and time and timezone. You’ll keep the right context even if lawmakers decide to switch things up. You want to see your doctor at 8:30 AM on Monday September 14, 2026 whether it’s daylight saving time, or standard time or “they” decide on a fractional hour offset between the time you set the appointment and the time you attend the appointment. Past events: UTC timest…

What about virtual events between participants in different time zones? Whose do you keep stable if one has their clock moved under them?

If you're feeling nice, randomize whose time remains stable (to keep things fair), keep the organizer's time stable, or pick the time that minimizes the number of participants who will have the meeting time change.

If you're feeling mean, randomize whose time remains stable (to make it hard to predict), move the meeting for the organizer, pick the time that maximizes the number of participants who will have the meeting time change, or split the difference and move everyone. Meeting was at 10 AM for Alice and 9 AM for Bob, but now it can be at either 11 AM for Alice and 9 AM for Bob or 10 AM for Alice and 8 AM for Bob? Now the meeting is at 10:30 AM for Alice and 8:30 AM for Bob.

Re: British Columbia, Time Zones, and Postgres

#65
This is one of those cases where I would prefer to be antifragile and rapidly "patch the data" once as opposed to trying to perfectly solve problems like this before they arise. In all likelihood this will never happen in a particular timezone.

Re: British Columbia, Time Zones, and Postgres

#66
post #44

Future events: store the local (at the event) date and time and timezone. You’ll keep the right context even if lawmakers decide to switch things up. You want to see your doctor at 8:30 AM on Monday September 14, 2026 whether it’s daylight saving time, or standard time or “they” decide on a fractional hour offset between the time you set the appointment and the time you attend the appointment. Past events: UTC timest…

> What format should you use? Human readable strings for longterm storage, because when things go wonky, it’s easier to debug. You can just use a TIMESTAMP with no TZ data. It's functionally the same as using the string but simpler because you avoid all the string handling headaches and gain the benefit of avoiding to avoid double booking and date/time functions to answer questions like "how many appointments do I ha…

I am willing to concede to “human readable” and dropping “string” iff queries on TIMESTAMP are producing a human readable string (I believe they are … I haven’t been in postgres in at least six weeks and details like that don’t make a lasting impression in muh brain)

Re: British Columbia, Time Zones, and Postgres

#67
post #52

Earlier quoted context omitted.

For the 2026a release: Changes to past and future timestamps Since 2022 Moldova has observed EU transition times, that is, it has sprung forward at 03:00, not 02:00, and has fallen back at 04:00, not 03:00. (Thanks to Heitor David Pinto.)

Interesting. I could see that as an argument also for storing it in UTC, no? For example, if tzdata is 1 hour off, and you store your timestamps in UTC, it's immediately obvious that a local time is wrong because users will see events that just happened as having happened 1 hour ago. Update tzdata, and now everything is right. If you store the wall time, it _looks_ right, but fails if you attempt to compare/sort it w…

Only for server-supplied timestamps.

Like the time clock example: sure what you're describing works if the user is just pressing a button to clock in and the server stores a UTC timestamp in response to a POST request or whatever.

But it's very common to need to backfill time. So the user backfills with their own supplied timestamps, those stamps get converted to UTC, tzdata changes a few months later, and HR is now asking for an explanation as to why they were late for those backfills and how it's possible they were working an hour after the shop closed.

It's never as simple as "just store it in UTC".

Conversion to UTC is lossy, so I prefer to keep up with the user-supplied time where appropriate.

Re: British Columbia, Time Zones, and Postgres

#68
post #33

I hope this gives us Americans the needed encouragement to do the same on the west US coast. Utter insanity to screw with the clocks twice a year instead of letting various institutions who have a compelling need, to publish "Summer hours" to suit them.

Apparently there is a Federal restriction: we can opt to eliminate DST, like Hawaii and Arizona, but we cannot unilaterally decide to adopt "permanent DST" as did British Columbia. So we'll have to figure out how to get both houses of Congress to pass a bill into law, and have the President sign it, without said institutions convincing the world that keeping your clocks 1 hour forward is woke propaganda and injects g…

Isn't the simple option to just move time zones? If you're not allowed to swap to PDT year round, just change to MST instead.

Re: British Columbia, Time Zones, and Postgres

#69

Future events: store the local (at the event) date and time and timezone. You’ll keep the right context even if lawmakers decide to switch things up. You want to see your doctor at 8:30 AM on Monday September 14, 2026 whether it’s daylight saving time, or standard time or “they” decide on a fractional hour offset between the time you set the appointment and the time you attend the appointment. Past events: UTC timest…

What about virtual events between participants in different time zones? Whose do you keep stable if one has their clock moved under them?

This is the critical problem with all of this.

Daylight savings time changes, can't be globally banned fast enough really.

Re: British Columbia, Time Zones, and Postgres

#70
post #43

The issue here seems to be that the behavior of tzdata (correctly) changes over time. Can all this complexity be avoided by storing the tzdata version in the timestamp itself so it can decoded with the same rules?

It's just a different kind of complexity and one that requires having a library that can arbitrarily load different versions of tzdata.

I've been thinking about it for a while though - a time zone conversion library that also accepts an additional "tzdata_version" argument.

Post reply on HN