sunshine@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 12 hours agoI'm new to using Ruby and this tickled me pinkimagemessage-square52fedilinkarrow-up1157arrow-down14
arrow-up1153arrow-down1imageI'm new to using Ruby and this tickled me pinksunshine@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 12 hours agomessage-square52fedilink
minus-squareBoomer Humor Doomergod@lemmy.worldlinkfedilinkEnglisharrow-up23·11 hours agoAnd the best part is the Ruby way accounts for leap years.
minus-squaredeadbeef79000@lemmy.nzlinkfedilinkarrow-up17·9 hours agoWell, 365 * 10 certainly doesn’t ;-)
minus-squarepulsey@feddit.orglinkfedilinkarrow-up2·5 hours agothere is a simple fix to account for leap years, just add 10/4 days. /s
minus-squareEager Eagle@lemmy.worldlinkfedilinkEnglisharrow-up8arrow-down2·9 hours agoI prefer the one on the left because it’s evident it doesn’t account for leap days, while I’d be questioning whether the one on the right does.
minus-squareDiplomjodler@lemmy.worldlinkfedilinkarrow-up2·edit-23 hours agoI’ll give it a shot. Looks a bit kludgy and I’ve been typing this on my phone while sitting on the toilet. What am I doing with my life? from datetime import datetime now = datetime.now() year = now.strftime('%Y') month = now.strftime('%m') day = now.strftime('%d') tenyearsago = datetime(year-10, month, day) print(tenyearsago.strftime('%d.%m.%Y')
minus-squareDigital Mark@lemmy.sdf.orglinkfedilinkEnglisharrow-up1·1 hour agoAnd what happens when you run that on Feb 29, 2024?
And the best part is the Ruby way accounts for leap years.
Well,
365 * 10
certainly doesn’t ;-)there is a simple fix to account for leap years, just add 10/4 days. /s
I prefer the one on the left because it’s evident it doesn’t account for leap days, while I’d be questioning whether the one on the right does.
I’ll give it a shot. Looks a bit kludgy and I’ve been typing this on my phone while sitting on the toilet. What am I doing with my life?
And what happens when you run that on Feb 29, 2024?