▲ 272 ▼ I'm new to using Ruby and this tickled me pink (lemmy.ml) submitted 1 year ago by sunshine@lemmy.ml to c/programmerhumor@lemmy.ml 72 comments fedilink hide all child comments
[–] Semi_Hemi_Demigod@lemmy.world 31 points 1 year ago (4 children) And the best part is the Ruby way accounts for leap years. permalink fedilink source hideshow 4 child comments replies: [–] deadbeef79000@lemmy.nz 22 points 1 year ago Well, 365 * 10 certainly doesn't ;-) permalink fedilink source parent [–] eager_eagle@lemmy.world 10 points 1 year ago (2 children) 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. permalink fedilink source parent hideshow 2 child comments replies: [–] Diplomjodler3@lemmy.world 3 points 1 year ago* (1 child) 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? 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') permalink fedilink source parent hideshow 1 child comment replies: [–] eager_eagle@lemmy.world 3 points 1 year ago or just this from datetime import datetime today = datetime.today() ten_years_ago = today.replace(year=today.year - 10) print("Date 10 years ago:", ten_years_ago.date()) permalink fedilink source parent
[–] deadbeef79000@lemmy.nz 22 points 1 year ago Well, 365 * 10 certainly doesn't ;-) permalink fedilink source parent
[–] eager_eagle@lemmy.world 10 points 1 year ago (2 children) 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. permalink fedilink source parent hideshow 2 child comments replies: [–] Diplomjodler3@lemmy.world 3 points 1 year ago* (1 child) 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? 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') permalink fedilink source parent hideshow 1 child comment replies: [–] eager_eagle@lemmy.world 3 points 1 year ago or just this from datetime import datetime today = datetime.today() ten_years_ago = today.replace(year=today.year - 10) print("Date 10 years ago:", ten_years_ago.date()) permalink fedilink source parent
[–] Diplomjodler3@lemmy.world 3 points 1 year ago* (1 child) 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? 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') permalink fedilink source parent hideshow 1 child comment replies: [–] eager_eagle@lemmy.world 3 points 1 year ago or just this from datetime import datetime today = datetime.today() ten_years_ago = today.replace(year=today.year - 10) print("Date 10 years ago:", ten_years_ago.date()) permalink fedilink source parent
[–] eager_eagle@lemmy.world 3 points 1 year ago or just this from datetime import datetime today = datetime.today() ten_years_ago = today.replace(year=today.year - 10) print("Date 10 years ago:", ten_years_ago.date()) permalink fedilink source parent