Live data from Hacker News

British Columbia, Time Zones, and Postgres

crunchydata.com

21–30 of 117 posts

Re: British Columbia, Time Zones, and Postgres

#21
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.

Re: British Columbia, Time Zones, and Postgres

#22
post #8
post #5

Earlier quoted context omitted.

The issue described in the post is an example of when you cannot just rely on Unix timestamps. Specifically it comes down to which date is authoritative. A appointment with your dentist at 2pm Pacific Time in December 2026 has changed Unix timestamps in British Columbia. The dentist doesn't care about the Unix timestamp, she cares about the wall clock local time when you arrive for the appointment.

"Which date is authoritative". I don't understand this. The consumer books in his/ her local time stamp i.e. 12 PM pacific. Gets stored as Epoch milliseconds (and is passed around as a data structure i.e. Date struct with UTC as the timezone) and the providers sees the time stamp 3 PM EST or 2 PM CST depending on it's timezone at runtime (interface the provider it works with). I don't understand why a specific timezo…

The appointment is for 12/1/26 2PM of whatever timezone the office is in at the time of the appointment.

Between the time of booking and the time of the appointment, the government changed what timezone there will be at the time of the appointment. If you calculated the Unix timestamp at the time of booking using the old laws, by the time of the appointment the Unix timestamp would be off by an hour.

Re: British Columbia, Time Zones, and Postgres

#24
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.

You're right that for the most part this is avoided by convention and scheduling time changes at quiet times of day.

A bit contrived but consider you are a maintenance worker in a facility that uses isolated timekeeping devices. "Change the clock on the vault back one hour at 3:00am".

Re: British Columbia, Time Zones, and Postgres

#25
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.

Sounds like the quoted RFC would help here. Storing the offset would make it unambiguous which of the two moments was meant. Your business logic would have to figure out what to do when the offset no longer exists (honour the clock time or convert to the new timezone) or is nonsense. The geographical reference would help decide what to do if you're not in a single location.

Re: British Columbia, Time Zones, and Postgres

#26

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…

UTC for past events doesn't always work either. For example, historical employee punch-in times.

UTC timestamps should only ever be used for points in time in the most literal sense, and nothing else.

Re: British Columbia, Time Zones, and Postgres

#27
post #3

I would contend that you shouldn't store anything but current unix timestamps in UTC in your database. If you must store time in some other way, then the two column method in the post will work, but leave it up to your software library to do it. I prefer to leave all the time conversions to software, wherein you only use battle tested libraries, and never do it by hand. Timezones are just too fraught with peril to tr…

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.

Re: British Columbia, Time Zones, and Postgres

#28
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 encountered it when I was design the scheduling back-office for a LED video wall a few years ago when those became economical for a shop to own and run 24/7.

The customer probably never noticed if I even did it “correctly” or couldn't be bothered if I didn't, but I remember I was bothered by it: (1) ensuring continuity of programming during the gap when it jumps forward (2) solving the ambiguity when it went backwards.

Because obviously they wanted to think in local time.

Re: British Columbia, Time Zones, and Postgres

#29
An added wrinkle is that parts of British Columbia use other timezones.

The southeast corner follows Alberta time (previously MST/MDT but changing to MDT).

Parts of the northeast and iirc a few other communities (eg Creston) have historically followed MST (no switch) and will now be effectively on the same time as Vancouver, albeit probably with a different TZ designation(?).

Post reply on HN