HackerTrans
TopNewTrendsCommentsPastAskShowJobs

ewi_

no profile record

comments

ewi_
·3 anni fa·discuss
When you store the time of a future event (like a reminder for 1 year from now), and integer since epoch does not work.

Your event is initially in the user's timezone (e.g. 10am 20th of June 2024 in France), if you store it as a number then you are fixing the exact second at which it will happen. However, if the timezone in question has some changes you didn't anticipate (new law voted, no more summer time), then you will either be triggering your event 1h before (e.g. 9am instead of 10am) which is probably not what your user wanted, or you'll have to recompute all your timestamps to take that change into account.

Instead, you could store rhe event with the target timezone, and let your datetime library that is up to date figure out next year.
ewi_
·3 anni fa·discuss
Very good point, which is a reminder that you have different "types" of dates that you may want to store.

Went storing the time at which an event happened (e.g. for a system log) then a UTC or UNIX time works, and it will be transformed at display time depending on the user's timezone.

When storing a future time at which to do something, it should be stored with its target timezone so you can always make sure it happens at the right moment. For this iso datetime representation makes a lot of sense.