https://xkcd.com/2867

Alt text:

It’s not just time zones and leap seconds. SI seconds on Earth are slower because of relativity, so there are time standards for space stuff (TCB, TGC) that use faster SI seconds than UTC/Unix time. T2 - T1 = [God doesn’t know and the Devil isn’t telling.]

  • ericbomb@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    11 months ago

    We use datediff in sql and let God handle the rest.

    “Oh but they’re in different time zones” “Oh did you account for if one is in day light savings and other isn’t” “Aren’t some of these dates stored in UTC and some local?”

    Are all problems I do not care about.

  • Alien Nathan Edward@lemm.ee
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    11 months ago

    I just spent two days debugging a reporting endpoint that takes in two MM-YYYY parameters and tries to pull info between the first day of the month for param1 and the last day of the month for param2 and ended up having to set my date boundaries as

    LocalDate startDate = new LocalDate(1, param1.getMonth(), param2.getYear()); //pretty straightforward, right?

    //bump month by one, account for rollover, set endDate to the first of that month, then subtract one day

    int endMonth = param2.month == 12 ? param2.month + 1 : 1;

    LocalDate endDate = new LocalDate(1, endMonth, param2.year).minusDays(1);

    This is extraordinarily simply for humans to understand intuitively, but to code it requires accounting for a bunch of backward edge/corner case garbage. The answer, of course, is to train humans to think in Unix epoch time.

        • Jarix@lemmy.world
          link
          fedilink
          English
          arrow-up
          0
          ·
          11 months ago

          Would you mind trying to explain (ELI5 style) what you did before and why you are excited for this new method for those of us who dont understand code?

          • Alien Nathan Edward@lemm.ee
            link
            fedilink
            English
            arrow-up
            0
            ·
            11 months ago

            it does in a way that’s been reviewed, vetted and tested by a lot of people the thing that I’m trying to do with code that’s only ever been seen by me and one other guy and has been tested to this best of my ability, which i hope is quite good but one person can easily miss edge cases and weird coincidences.

            • Jarix@lemmy.world
              link
              fedilink
              English
              arrow-up
              0
              ·
              11 months ago

              So how is the new thing different/better (other than less lines i guess?) If you dont me asking

              • hikaru755@feddit.de
                link
                fedilink
                English
                arrow-up
                0
                ·
                edit-2
                11 months ago

                It’s easier to understand, easier to review for correctness, and less likely to cause problems with additional changes in the future. Even though it sounds counterintuitive, software developers generally try to write as little code as possible. Any code you write is a potential liability that has to be maintained, so if you can instead just call code that others have already written and that has been tested, you’ll want to do that. (Note that “less code” doesn’t mean fewer lines of code, it means less logical complexity, which is often, but not always, also less in terms of characters/lines)

                • Jarix@lemmy.world
                  link
                  fedilink
                  English
                  arrow-up
                  0
                  ·
                  11 months ago

                  So like my english teacher taught me. Keep It Stupid Simple(though he would say keep it simple stupid to some people in class i am just realizing now 20+ years later)

    • lad@programming.dev
      link
      fedilink
      English
      arrow-up
      0
      ·
      11 months ago

      This one is good (or evil, depends on how you see it):

      Human-readable dates can be specified in universally understood formats such as 05/07/11.

      • elvith@feddit.de
        link
        fedilink
        English
        arrow-up
        0
        ·
        11 months ago

        That one’s really good.

        Which one is it?

        • July 5th 2011
        • May 7th 2011
        • July 11th 2005
        • November 7th 2005

        And is it 2011/2005 or rather 1911/1905, 1811/1805,…?

    • randy@lemmy.ca
      link
      fedilink
      English
      arrow-up
      0
      ·
      11 months ago

      I really wish that list would include some explanations about why each line is a falsehood, and what’s actually true. Particularly the line:

      The software will never run on a space ship that is orbiting a black hole.

      If the author has proof that some software will run on a space ship that is orbiting a black hole, I’d be really interested in seeing it.

      • elvith@feddit.de
        link
        fedilink
        English
        arrow-up
        0
        ·
        11 months ago

        All links to the original article are dead and even archive.org doesn’t have a capture either. I guess the argument is along the lines of “it might not be relevant, when you’re scripting away some tasks for your small personal projects, but when you’re working on a widely used library or tool - one day, it might end up on a space vessel to explore whatever.”

        E.g. my personal backup script? Unlikely. The Linux kernel? Somewhat plausible.

      • kurwa@lemmy.world
        link
        fedilink
        English
        arrow-up
        0
        ·
        11 months ago

        I got to “The day before Saturday is always Friday” and I was like waaaa?

        • lad@programming.dev
          link
          fedilink
          English
          arrow-up
          0
          ·
          11 months ago

          I thought it is about when Julian calendar was dropped in favour of Gregorian, but that’s not it:

          Thursday 4 October 1582 was followed by Friday 15 October 1582

          • elvith@feddit.de
            link
            fedilink
            English
            arrow-up
            0
            ·
            edit-2
            11 months ago

            Also some of the islands around the International Date Line did switch their stance on which side of the Date Line they are. So… they might have had a day twice or lost a whole day in the process. And maybe, they didn’t change sides only once…

            E.g. see here https://youtu.be/cpKuBlvef6A