you are viewing a single comment's thread
view the rest of the comments
[–] 13 points 1 year ago (4 children)

crystal is another language that's apparently quite similar to ruby, with the difference of being compiled and staticly type-checked, and I just love it's ruby like syntax. I believe the equivalent code for this in crystal would be Time.local - 10.years

  • source
  • hideshow 4 child comments
  • [–] 2 points 1 year ago (3 children)

    one could certainly implement something like that in python, something like time.now - 10 * time.unit.year

  • source
  • parent
  • hideshow 3 child comments
  • [–] 1 point 1 year ago (2 children)

    Does this account for leap years?

  • source
  • parent
  • hideshow 2 child comments
  • [–] 3 points 1 year 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.

  • source
  • parent
  • hideshow 1 child comment