This doesn't cut it
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
sunshine@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 1 day ago

I'm new to using Ruby and this tickled me pink

lemmy.ml

message-square
87
fedilink
  • cross-posted to:
  • programmer_humor@programming.dev
259

I'm new to using Ruby and this tickled me pink

lemmy.ml

sunshine@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 1 day ago
message-square
87
fedilink
  • cross-posted to:
  • programmer_humor@programming.dev
  • Kazumara@discuss.tchncs.de
    link
    fedilink
    arrow-up
    20
    ·
    23 hours ago

    The python version seems buggy as fuck. Depending on which year you run it it’s off by 1-3 days

    • dumples@midwest.social
      link
      fedilink
      English
      arrow-up
      6
      arrow-down
      1
      ·
      19 hours 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
        2
        ·
        9 hours 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

    • comfy@lemmy.ml
      link
      fedilink
      arrow-up
      2
      ·
      22 hours ago

      That sounds serious, can you give some example values we can test?

      • Kazumara@discuss.tchncs.de
        link
        fedilink
        arrow-up
        9
        ·
        20 hours ago

        Sure, here’s one example for each case:

        1 day off: 3650 days before 1907-01-01 is 1897-01-02

        2 days off: 3650 days before 2027-01-01 is 2017-01-03

        3 days off: 3650 days before 2025-01-01 is 2015-01-04

      • mrgoosmoos@lemmy.ca
        link
        fedilink
        English
        arrow-up
        10
        ·
        21 hours 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?

        • Crashumbc@lemmy.world
          link
          fedilink
          English
          arrow-up
          2
          ·
          20 hours ago

          Yes, and I have no idea…

          • Hupf@feddit.org
            link
            fedilink
            arrow-up
            1
            ·
            3 hours ago

            https://youtu.be/-5wpm-gesOY

          • Kazumara@discuss.tchncs.de
            link
            fedilink
            arrow-up
            4
            ·
            edit-2
            3 hours 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
              2
              ·
              11 hours 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
                1
                ·
                3 hours 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)

      • gonzo-rand19@moist.catsweat.com
        link
        fedilink
        arrow-up
        3
        ·
        20 hours ago

        29 February 2028, 29 February 2032, 29 February 2036…

Programmer Humor@lemmy.ml

programmerhumor@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmerhumor@lemmy.ml

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 485 users / day
  • 912 users / week
  • 3.59K users / month
  • 8.89K users / 6 months
  • 1 local subscriber
  • 37.9K subscribers
  • 1.81K Posts
  • 35.6K Comments
  • Modlog
  • mods:
  • AgreeableLandscape@lemmy.ml
  • cat_programmer@lemmy.ml
  • BE: 0.19.8
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org