Follow

uncle brion's hard-won guide to timestamps 

1) there are two valid storage formats: elapsed seconds since a known epoch (Unix or otherwise), or ISO 8601 including a timezone

2) never try to convert between them yourself. use operating system or standard library facilities.

3) if you are storing a human-visible local time, DO NOT STORE BARE LOCAL TIME. store UTC and the timezone identifier.

4) do not attempt to convert time zones yourself. use the operating system or standard library facilities.

· · Web · 3 · 7 · 22

uncle brion's hard-won guide to timestamps 

oh and 5) if you want to calculate time spans between two points in time, other than an exact number of elapsed seconds?

weep.

uncle brion's hard-won guide to timestamps 

@brion even “exact number of elapsed seconds” sounds very tricky

uncle brion's hard-won guide to timestamps 

@ehabkost *laughs in leap seconds* ;)

uncle brion's hard-won guide to timestamps 

@brion @ehabkost yeah but at least for that standard library functions are good enough.

Oh unless you want to use future dates and have the result remain constant.

uncle brion's hard-won guide to timestamps 

@brion This is one of those things that everybody has learned the hard way themselves. Come to think of it, it makes a great interview question.

uncle brion's hard-won guide to timestamps 

@brion And I thought: Forget about time. Use logical clocks and never look back 😉

Sign in to participate in the conversation
Mastodon for Tech Folks

This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either!