▲ 279 ▼ I'm new to using Ruby and this tickled me pink (lemmy.ml) submitted 11 months ago by sunshine@lemmy.ml to c/programmerhumor@lemmy.ml 87 comments fedilink hide all child comments
[–] Feathercrown@lemmy.world 1 point 11 months ago (1 child) Does this account for leap years? permalink fedilink source parent hideshow 2 child comments replies: [–] hinterlufer@lemmy.world 3 points 11 months ago (1 child) I don't think this is implemented in the standard datetime library, but in principle overriding sub is easily possible and you can define it as you'd wish. However, I think subtracting a year is a bit ill defined, because it isn't clear which year you're subtracting given the leap year issue. permalink fedilink source parent hideshow 2 child comments replies: [–] Feathercrown@lemmy.world 3 points 11 months ago If you're subtracting a year from a date, you could just keep the date constant while changing the year, and adjust Feb 29 as needed. permalink fedilink source parent
[–] hinterlufer@lemmy.world 3 points 11 months ago (1 child) I don't think this is implemented in the standard datetime library, but in principle overriding sub is easily possible and you can define it as you'd wish. However, I think subtracting a year is a bit ill defined, because it isn't clear which year you're subtracting given the leap year issue. permalink fedilink source parent hideshow 2 child comments replies: [–] Feathercrown@lemmy.world 3 points 11 months ago If you're subtracting a year from a date, you could just keep the date constant while changing the year, and adjust Feb 29 as needed. permalink fedilink source parent
[–] Feathercrown@lemmy.world 3 points 11 months ago If you're subtracting a year from a date, you could just keep the date constant while changing the year, and adjust Feb 29 as needed. permalink fedilink source parent