Hacker News new | ask | show | jobs
by csytan 5256 days ago
Months and years are tricky because they can consist of a variable number of days. To me, it's a better way of handling things without being ambiguous. For example, is one month from now exactly 30 days from today, or is it the next month on the same month day? It's pretty simple to do either with the datetime library.

When taking into account DST, you should first convert from local time to UTC (pytz does this) before doing your calculations, then convert it back to local time if needed.

And yes, you do get a delta when subtracting two dates.

2 comments

> Months and years are tricky because they can consist of a variable number of days.

Then again, days can consist of a variable number of seconds due to e.g. the leap second.

yes, it's very damn tricky. That's why I want the lib to figure it out once and correctly.