• dumples@midwest.social
      link
      fedilink
      English
      arrow-up
      5
      arrow-down
      1
      ·
      5 days ago

      Python does have a year option that they are not using. Depending on the application I would use 365 for a year to get a consistent number of days.

      • sunshine@lemmy.mlOP
        link
        fedilink
        arrow-up
        7
        ·
        5 days ago

        I did look up the help for that function to make this meme but I must have missed that option. in my defense I’ve only been using Python for like 10 years

      • mrgoosmoos@lemmy.ca
        link
        fedilink
        English
        arrow-up
        10
        ·
        5 days ago

        look I’m not trying to be a dick or anything, but do you not know about leap years and which years they are?

        • comfy@lemmy.ml
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          4 days ago

          edit: just realized it was the python and not ruby example, I was very tired and distracted when I was reading this thread.

          • Kazumara@discuss.tchncs.de
            link
            fedilink
            arrow-up
            4
            ·
            edit-2
            5 days ago

            Leap years are each fourth year, except each hundredth year, except each thousandth fourhundredth year.

            1896 leap year
            1900 not leap year
            1904 leap year

            1996 leap year
            2000 leap year
            2004 leap year

            2096 leap year
            2100 not leap year
            2104 leap year

            Then you just arrange the 10 year window in different positions to overlap 1 to 3 leap years to reveal the three outcomes of the bug.

            - / - - - / - - - /
            - - / - - - / - - -
            - - 0 - - - / - - -

            - is a normal year, / is a leap year, 0 is an exceptional non-leap year.

            • sexybenfranklin@ttrpg.network
              link
              fedilink
              English
              arrow-up
              3
              ·
              5 days ago

              Small correction, it’s every fourth year except every hundreth year except every 400th year. I’m assuming the misconception comes from the last time it was a 100th also being a 1000th (2000) but the next time a leap year will end in 00 is 2400

              • Kazumara@discuss.tchncs.de
                link
                fedilink
                arrow-up
                3
                ·
                5 days ago

                Ahh right! Thanks for correcting me. Now that you mention it I remember too. It also makes sense, a year is roughly 365.2425 days long. Add 0.25 (one out of four), subtract 0.01 (one out of hundred), add another 0.0025 (2.5 out of thousand which is 1 out of 400)