Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Doesn't do months or years. Who knows how it handles dst transitions.

I can't remember for sure but I don't think you can subtract two dates and get a delta?



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.


> 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: