• AggressivelyPassive@feddit.de
      link
      fedilink
      arrow-up
      10
      ·
      4 months ago

      Or requires a timestamp with zone offset, but ignores the zone offset, so you have to send the timestamp itself with a zone offset of zero relative to the systems timezone, but can’t just omit the zone offset, because it’s required.

    • bleistift2@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      7
      ·
      4 months ago

      When the API returns UTC, but mandates that you give it an offset which it will add or subtract from the UTC time, while still adding the Z at the end.

  • ByteJunk@lemmy.world
    link
    fedilink
    arrow-up
    42
    ·
    edit-2
    4 months ago

    It should be implemented in people’s brains.

    How this goes, usually, is:

    Them:…before 6PM.

    Me: 6PM… Ours? The server’s? The user’s?

    Them: GMT, of course.

    Me: So that’s 7PM London right now, and changes to 6PM in November?

    Them: What no are you stupid. Always 6PM GMT.

    Me:* jumps off a cliff*

    • mox@lemmy.sdf.org
      link
      fedilink
      arrow-up
      18
      arrow-down
      2
      ·
      4 months ago

      Them: GMT, of course.

      Me: So that’s 7PM London right now, and changes to 6PM in November?

      Them: What no are you stupid. Always 6PM GMT.

      Me:* jumps off a cliff*

      Sorry, but are you under the impression that GMT means London time, or that it observes British Summer Time?

      • my_hat_stinks@programming.dev
        link
        fedilink
        arrow-up
        11
        ·
        4 months ago

        UK is under BST (UTC+1) for half the year but people are usually just taught that the UK is GMT (UTC+0) which is based in the time in Greenwich, withought mentioning DST. I suppose it’s also possible everyone is taught BST and just forgets about it because daylight savings sucks, but either way most people seem to think GMT and UK time are the same thing.

        This means you’ll get people asking for GMT times when they want BST or UK local time.

      • caden@lemmy.sdf.org
        link
        fedilink
        arrow-up
        2
        ·
        4 months ago

        I too was similarly confused by the original comment at first, but I think they’re referring to the fact that 6pm GMT is 7pm in London during the summer (BST), and 6pm in London the rest of the year. It seems OP and “them” are both correct in that hypothetical exchange.

      • ruk_n_rul@monyet.cc
        link
        fedilink
        arrow-up
        1
        ·
        4 months ago

        The term UT is specifically created to divorce universal timekeeping from whatever UK’s timezone is doing, whether DST is on or not, etc. and the derived term UTC for when started adding leap seconds.

        GMT hasn’t been a thing since UTC. It should be scrubbed from the vocabulary and old farts still using it should be shunned and reeducated.

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

    So just for additional context:

    This meme was brought to you by the following API response scheme:

    {
      "time": "2007-12-24 18:12",
      "servertimezone": "Europe/Vienna",
      "timezoneoffset": -8
    }
    

    when it could have just been

    {
      "date": "2007-12-24T18:21:00-07:00"
    }
    
    • gjoel@programming.dev
      link
      fedilink
      arrow-up
      6
      ·
      4 months ago

      To be fair, returning the actual timezone (as defined by tz.db) is useful if you don’t just want the current time since you’ll be able to take DST into account. Not sure how Vienna is -8 though, it should be +1 (or 2 depending on DST).

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

        Just for further clarification, the API works like this:

        • time is the local (client) time (in this case UTC-7)
        • servertimezone is the time zone where the server is located
        • timezoneoffset is the offset of the local time relative to the servertimezone (offset from the servers PoV)

        To get the UTC date you have to do something like this:

        time.minusHours(timezoneoffset).atZone(servertimezone).toUTC()
        
      • el_abuelo@lemmy.ml
        link
        fedilink
        arrow-up
        3
        ·
        4 months ago

        Your comment is a full throated endorsement of just working in UTC up until the presentation layer. Whether you intended that or not is another question.

        • gjoel@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          4 months ago

          It is? Without even mentioning it?

          To be clear I believe it makes sense to do a lot of things in UTC, but future events should almost always be local time + timezone to make scheduling predictable and consistent to humans.

          • el_abuelo@lemmy.ml
            link
            fedilink
            arrow-up
            3
            ·
            4 months ago

            Yes. Not intentionally of course. But yes.

            I don’t see how your way is any more predictable or consistent than using UTC. What even is “local time”? Are you assuming they haven’t changed timezone since they created the data? Say…DST happened, or they drove over a border…?

            Storing and manipulating in UTC is the most predictable and consistent because it is universal and unchanging. You only need to worry about “local time” at the point of displaying it.

            • gjoel@programming.dev
              link
              fedilink
              arrow-up
              2
              ·
              4 months ago

              We have slackbots that post, for instance, who has vecation every day. Because it is configured to post this using UTC, the time of day this is posted changes twice a year.

              I might have a recurring appointment for lunch in my calendar every day at noon. Now DST happened, so I have to wait until one to eat. That is inconsistent to me.

              Timezones change. If I have to go to the theatre on half a year at 18:00, I don’t want to be there at 19:00 because someone decided local time would be better if we moved it an hour. The show time certainly won’t be moved.

              What is local time? It’s spacetime. When did it happen and if relevant (eg. a photo) what was the offset (because I would like to know the time of day)? When will it happen, and where? Online meetings across timezones are tricky, of course, but excluding the timezone won’t improve that.

              • ruk_n_rul@monyet.cc
                link
                fedilink
                arrow-up
                1
                ·
                4 months ago

                Notice the common problem here? DST. Get rid of it and you get rid of the inconsistency that happens parts of the year, and you reduce fatality rates that resulted from moving time twice a year.

                • gjoel@programming.dev
                  link
                  fedilink
                  arrow-up
                  1
                  ·
                  4 months ago

                  I agree! Can we also get rid of politicians, mosquitoes and people who use their phone at the cinema?

  • CodeBlooded@programming.dev
    link
    fedilink
    arrow-up
    33
    arrow-down
    10
    ·
    4 months ago

    Mandating UTC everywhere and eliminating the concept of time zones altogether is all a political candidate needs to do in order to earn my vote in 2024.

    Seriously, what is the point of time zones? The only explanation I’ve ever heard is “well if we didn’t have time zones, half the world would be expected to be awake when it’s dark out!” No. We could all just literally adjust the times of our business operations based around when daylight is usual for the different geographic regions as they have the sun shine on them. The physical “zones” of time zones could remain the same, and in those zones “noon” would just mean something other than “12:00.” “Noon” for one region could be 2300 while what is considered “noon” for another region could be 1800.

    (And for my next rant: why the 24 hour clock is superior to the 12 hour clock… reason number 1? There’s 24 hours in a day…)

    • DudeDudenson@lemmings.world
      link
      fedilink
      arrow-up
      25
      ·
      4 months ago

      What you’re proposing is literally time zones but without shifting the actual clock, you still end up with all the issues and you remove the link between the hour of day and the sun’s position for people lol

      Plus who gets to decide that everyone switches over and what is the new global time?

      • CodeBlooded@programming.dev
        link
        fedilink
        arrow-up
        6
        arrow-down
        4
        ·
        4 months ago

        Yes, this is literally what I’m proposing.

        You do not still end up with the same issues. Somebody booking a ticket for a hotel room to be available at 1300 from a different time zone than said hotel will not arrive at the hotel to learn that the check in time is different from their expectation.

        Regarding “the link between the hour of the day and the sun’s position,” I’m asserting that we should recalibrate this expectation based on time zones, rather than changing the clock to some fictitious time based on “noon” always equaling “1200.”

        who gets to decide that everyone switches over and what is the new global time?

        “Global time” in this context is already decided to be UTC. And no one gets to decide on the switch. This is a dream that will never come to fruition. 😕

        • state_electrician@discuss.tchncs.de
          link
          fedilink
          arrow-up
          6
          arrow-down
          1
          ·
          4 months ago

          Haha, let’s inconvenience 99.9% of humans so some programmers have a slightly easier life. I’ve had my share of frustration with time zones, but this change is so enormous, that it’s in no way appropriate.

          • CodeBlooded@programming.dev
            link
            fedilink
            arrow-up
            2
            arrow-down
            1
            ·
            edit-2
            4 months ago

            I don’t think it’s actually realistic that this would ever change at this point in the game. I do think we could have adapted to all using UTC if we never started with time zones in the first place.

          • CodeBlooded@programming.dev
            link
            fedilink
            arrow-up
            3
            arrow-down
            3
            ·
            4 months ago

            Yes. Many people already work shifts that have them do exactly that (show up to work on Monday, go home on Tuesday).

            My first job had me work all sorts of shifts. Anything other than the day shift, I was showing up early or late evening one day, and leaving work early or late morning the next day.

    • palordrolap@kbin.run
      link
      fedilink
      arrow-up
      17
      arrow-down
      1
      ·
      4 months ago

      Implementing such a change has another problem: Who gets to have the time-zone that’s noon at noon?

      Are we going to let the British continue to get away with it? Even the excuse of “that’s the way it has to be to keep things simple” would cause the French to revolt. Again. They still don’t like to talk about the fact that it’s Greenwich and not Paris that’s the prime meridian.

      Swatch’s “Internet time” was a decimal system designed to mitigate the problem because no-one would have any idea what the old time was supposed to be, but people are used to the base-60 system. It didn’t and won’t catch on.

      And it doesn’t fix the “0 isn’t my midnight” problem, which is pretty close to the original.

      It also doesn’t fix the “what time of day is it elsewhere in the world” problem, which still requires knowledge of time differences. You know. Time zones.

        • palordrolap@kbin.run
          link
          fedilink
          arrow-up
          3
          ·
          edit-2
          4 months ago

          I never said the time zone was GMT, only that the meridian is Greenwich. Subtle, yes, but if the meridian for UTC isn’t the one running through Greenwich, let me know.

          • bitchkat@lemmy.world
            link
            fedilink
            English
            arrow-up
            2
            ·
            4 months ago

            Actually you only mentioned timezone “who gets to have the time zone where noon is directly overhead” and then went into a rant about England vs France. You never once mentioned the meridian.

            • palordrolap@kbin.run
              link
              fedilink
              arrow-up
              1
              arrow-down
              1
              ·
              edit-2
              4 months ago

              They still don’t like to talk about the fact that it’s Greenwich and not Paris that’s the prime meridian.

              But sure, I didn’t explicitly connect the dots.

              • bitchkat@lemmy.world
                link
                fedilink
                English
                arrow-up
                1
                ·
                4 months ago

                We’re talking about this: “Who gets to have the time-zone that’s noon at noon?”

                That established the context that we are talking about time zones.

      • CodeBlooded@programming.dev
        link
        fedilink
        arrow-up
        6
        arrow-down
        2
        ·
        4 months ago

        Who gets to have the time-zone that’s noon at noon

        I am asserting that we abandon this concept of “noon” having to be precisely when the pixels on the my clock take the form of “12:00”.

        Who cares? Just let “noon” be whatever mid-day is where you live.

        0 isn’t my midnight

        Same thing, why does it matter? Why do people cling to this? Midnight should be when you are mid-way through the night, regardless of what time a clock shows.

        It also doesn’t fix the “what time of day is it elsewhere in the world” problem, which still requires knowledge of time differences. You know. Time zones.

        I don’t have time zones memorized, so I have to look up this information when I need to know it anyway. I did say in my post that the [time] “zones” would still exist if I had my way with UTC. I do still think it’s valuable to know the operating hours for different parts of the earth- I just think we can track this without having to have the madness that is time zones. However, while answering this, I do feel what you’re saying. Perhaps we do keep time zones, but only as a way to tell time that is secondary to UTC? (As compared to today, where UTC is often an afterthought, if people even think about it at all.)

        • palordrolap@kbin.run
          link
          fedilink
          arrow-up
          4
          arrow-down
          1
          ·
          4 months ago

          Stealing from another commenter: Are you OK with referring to days of the week as Tuesday/Wednesday, or do you propose abandoning day names altogether? If you say your local day is Tuesday which doesn’t align with someone else’s Tuesday, you’ve still got the old time-zone problem just at a coarser grain.

          As for “secondary time” yes. That’s called local time. Which is what the initial proposal was trying to be rid of.

          Now riddle me this: What time do you have your computer’s motherboard set to?

      • Butt Pirate@reddthat.com
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        edit-2
        4 months ago

        Plus people would go to work on a Tuesday but come home on Wednesday. Lol it would be an accounting nightmare.

        “Well the books for this company closed on the 1st, but the books for this other department within the company closed on the 2nd”.

    • psud@aussie.zone
      link
      fedilink
      arrow-up
      17
      arrow-down
      4
      ·
      4 months ago

      So organising a meeting for 03:30 has the problem of that not being working hours for some people, and you have to look up what working hours are in each area. What problem is that supposed to solve?

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

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

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

    • carrylex@lemmy.worldOP
      link
      fedilink
      arrow-up
      3
      ·
      4 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.

    • el_abuelo@lemmy.ml
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      4 months 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.

  • GTG3000@programming.dev
    link
    fedilink
    arrow-up
    13
    arrow-down
    1
    ·
    4 months ago

    Anything an API returns should just look like 1720533944.963659 .

    There’s no reason to store dates as anything other than UTC. User-side, sure, timezones are useful. Server doesn’t have to know.

    • Zagorath@aussie.zone
      link
      fedilink
      English
      arrow-up
      12
      ·
      edit-2
      4 months ago

      This is absolutely fundamentally wrong. What you’ve described is what Nodatime calls an Instant, and it’s a very important data class, but there are valid reasons to use other classes.

      A LocalDateTime cares about the date and time locally. An event scheduled for 8am every Monday might use this. It would update accordingly if you move locations to a new locale.

      A ZonedDateTime can almost be directly translated into an Instant, except that one time zone might change. If you go into or out of daylight saving time, or your region decides to change its time offset. Oslo time is still Oslo time. You use this if your event occurs at a specific time in a specific location.

      An OffsetDateTime is like a ZonedDateTime, but instead of being tied to a specific time zone (e.g. “Oslo time”) it’s tied to a specific UTC offset (e.g. UTC+1).

      You don’t have to use Nodatime, but you should at least think deeply about what your time objects actually represent and what is the best way to represent them.

      See the creator of Nodatime’s presentation about thinking deeply about time for more.

  • ik5pvx@lemmy.world
    link
    fedilink
    arrow-up
    12
    arrow-down
    1
    ·
    4 months ago

    There’s an even worse thing: timezone selection UIs that don’t let you choose UTC