Hacker News new | ask | show | jobs
by dragontamer 1102 days ago
> Do conversions to/from local time only as a first and last step.

Cool.

Now how do you enforce that? Spoiler: have the local-time be reported as a TimestampWithTimeZone.

When you're doing calculations, make them all Timestamps.

When you're done, you can remember that you've converted from internal UTC-timestamps into the proper output format because you'll have a TimestampWithTimezone again.

-----------

We're programmers. We have problems that are simple and enforceable through compiler constructs called "The Type System".

Why have the human figure out if they have time-zone back-and-forth correctly or otherwise made a mistake (ex: adding code to the wrong "part of the process" and accidentally mucking with a TimestampWithTimeZone input/output variable rather than the internal Timestamp-UTC-only type variables?)

Just... leave the job of checking this entire process to the compiler. If your n00b coworker messes up, the type system catches it and we're all set.