Hacker News new | ask | show | jobs
by xgbi 2294 days ago
And it better not. Timezone information has nothing to do in a timestamp.

A timestamp is a point in time, whatever the time is in Paris or Tokyo. It is an abstract value and it is way better this way.

A timezone is a filter through which you display your timestamp, and it tells you what your local time was when that timestamp occurred.

So yeah, always store and exchange time information as timestamps. Timezone is extra styling information, just like CSS.

3 comments

This is totally wrong, and a very dangerous way of handling date/time issues. If you set a wake-up alarm for 7am, you want that to go off at 7am in your local timezone, not 7am in whatever timezone you set the alarm in (which is what an ”absolute” time stamp would store).

There are lots of examples like this. Some time events you want to happen at absolute time points (in which case time zones are only for display purposes), but very often your events need to be ”time-zone aware”. There is no universal rule, and thinking that there is will lead to all sorts of trouble.

It's not wrong. What you're describing is not a timestamp.

A timestamp is a point in time, and is the same everywhere (excluding relativistic effects).

What you describe is definitely a valid use case (and having developed software that programs hardware that is controlled by a calendar, I have painful experience in this). However, it's not a timestamp. I'd call it time-of-day or wallclock. Some systems like SQL refers to it as simply "date" and "time". Whatever you prefer to call it, it's not a timestamp.

Could you add something saying explicitly what a timestamp _is_ under your terminology? Is it an integer offset from the UNIX era start?
It's an abstract concept. It's nothing more than a given point in time.

How you represent it doesn't change the definition. It could be stored as the number of seconds since some arbitrary point in time, such as Unix timestamp, or a Julian timestamp.

Or, it could be a given time and date combination with some fixed point of reference, such as UTC. I'm sure we all have favourite ways of representing timestamps.

Ok, one thing — perhaps not the most important — is that “timestamp” is a very unfortunate terminology for the abstract concept you describe. The word timestamp very much suggests that it’s referring to an explicit representation of some sort. “timepoint” would be much better for what you’re talking about. Not a criticism of you of course! I mostly write python at work so I rarely am directly exposed to the integer offset values, but I know many people use the word “timestamp” to refer to that integer, as opposed to a formatted string. Which also seems like unfortunate terminology, since what is a stamp if not formatted?
You are assuming that timezones don't change ever in relation to UTC. This is wrong. Timezones change all the time.

When I set an alarm for any time in CEST in 2022 and convert this to UTC before saving it, it will very likely ring at the wrong time, simply because CEST will probably not exist by then and be replaced by CET due to the EU getting rid of DST.

But an alarm is not supposed to use timestamps. An alarm is set for a certain time in a certain location. In otherwords, a wallclock time. Not a timestamp.
No, timezone information can be critical and assuming you can always strip it is just wrong.

You might not have encountered such scenarios but they are very much out there.

> No, timezone information can be critical and assuming you can always strip it is just wrong.

Expressing time based on the standard reference timezones (i.e., UTC) is not stripping the time zone away.

It is. Timezones change all the time in relation to UTC. If you set a date in the future and think converting it to UTC doesn't lose information, you will be surprised when you get bitten by it.

Example: The EU will most likely get rid of DST around 2022. Any time you set beforehand in CEST or CET will be an hour off, depending on which the EU will get rid of.aybe the EU doesn't get rid of DST and keeps it, you don't know. So unless you have a time machine, you cannot convert the time to UTC.

> A timestamp is a point in time, whatever the time is in Paris or Tokyo. It is an abstract value and it is way better this way.

> Timezone is extra styling information, just like CSS.

This is an incredibly reductive view of time data and the possible applications that use it.

Not all time data is timestamps, and UTC timestamps strip out information that is not "styling".