• Ugly Bob@sh.itjust.works
    link
    fedilink
    arrow-up
    19
    arrow-down
    1
    ·
    2 months 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@slrpnk.net
      link
      fedilink
      arrow-up
      15
      arrow-down
      1
      ·
      2 months ago

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

    • carrylex@lemmy.worldOP
      link
      fedilink
      arrow-up
      4
      ·
      2 months ago

      If you use utc here and a time zone definition changes, you’re boned

      I’m pretty sure that things like the tz database exist exactly for such a case.

    • BatmanAoD@programming.dev
      link
      fedilink
      arrow-up
      3
      ·
      2 months 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?

      • umbraroze@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        2 months 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.

        • booly@sh.itjust.works
          link
          fedilink
          arrow-up
          4
          ·
          edit-2
          2 months ago

          I think the comment is specifically talking about storing future times, and contemplating future changes to the local time zone offsets.

          If I say that something is going to happen at noon local time on July 1, 2030 in New York, we know that is, under current rules, going to happen at 16:00 UTC. But what if the US changes its daylight savings rules between now and 2030? The canonical time for that event is noon local time, and the offset between local time and UTC can only certainly be determined with past events, so future events defined by local will necessarily have some uncertainty when it comes to UTC.