• SHITPOSTING_ACCOUNT@feddit.de
    link
    fedilink
    arrow-up
    11
    ·
    1 year ago

    The most common date format used internally is “seconds since January 1st, 1970”.

    In early 2038, the number of seconds will reach 2^31 which is the biggest number that fits in a certain (also very common) data type. Numbers bigger than that will be interpreted as negative, so instead of January 2038 it will be in December 1901 or so.

    • BarqsHasBite@lemmy.ca
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      Huh interesting. Why 2^31? I thought it was done in things like 2^32. We could have pushed this to 2106.

      • SHITPOSTING_ACCOUNT@feddit.de
        link
        fedilink
        arrow-up
        10
        ·
        1 year ago

        Signed integers. The number indeed goes to 2^32 but the second half is reserved for negative numbers.

        With 8 bit numbers for simplicity:

        0 means 0.
        127 means 127 (last number before 2^(7)).
        128 means -128.
        255 means -1.

        • 257m@lemmy.ml
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          Why not just use unsigned int rather than signed int? We rarely have to store times before 1970 in computers and when we do we can just use a different format.

          • SHITPOSTING_ACCOUNT@feddit.de
            link
            fedilink
            arrow-up
            1
            ·
            1 year ago

            Because that’s how it was initially defined. I’m sure plenty of places use unsigned, which means it might either work correctly for another 68 years… or break because it gets converted to a 32 bit signed somewhere.

    • Hazdaz@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      so instead of January 2038 it will be in December 1901…

      Maybe this is just a big elaborate time travel experiment 68 years in the making?