• Ugly Bob
    link
    fedilink
    241 year ago

    There is one big caveat to universal time:

    Future dates: If you use utc here and a time zone definition changes, you’re boned. You have to store local time and offset for just this one usecase.

    • Natanael
      link
      fedilink
      171 year ago

      Store absolute time in something like Epoch (seconds since 1970-01-01) plus local time zone

    • @BatmanAoD@programming.dev
      link
      fedilink
      51 year ago

      Sorry, why would you be “boned” if you have UTC time? Are you thinking of the case where the desired behavior is to preserve the local time, rather than the absolute time?

      • Rose
        link
        fedilink
        31 year ago

        Not exactly boned but it probably doesn’t make practical difference to store “local time + tzinfo timezone” than just UTC time.

        • You record an event occurring at local time
        • You store it as UTC
        • Local time zone definition changes
        • Well whoop de loo, now you need to go through tzinfo to make sense of the past data anyway rather than relying on a known offset

        Even if you store everything in UTC, you may be safe… but figuring out the local time is still convoluted and involves a trip through tzinfo.

    • @el_abuelo@lemmy.ml
      link
      fedilink
      21 year ago

      So many things would be fucked by a TZ change that it very rarely makes sense to consider it.

      You’re making a calendar app? Fuck it…some folks are gonna get confused…solved by simply emailing your users and telling them to reschedule shit because there’s kind of a big event going on that everyone knows about and has been planning for for years. Hell in all liklihood this is probably easily solved by simply doing a mass migration of events scheduled before the TZ change.

      You’re coding for nuclear weapons? Maybe consider it. But probably not.

      That is to say: there are ways to solve problems without resorting to writing the most complicated bullshit code ever seen. Unless of course you work on my team - in which case you’d be right at home.