3 ms·
I figured you talk Python, that's good to know (x)! However, if you continue: >>> t = list(time.localtime()); t[2] -= 1; t[3:6] = [8,0,0]; print time.ctime
by lysium 15y ago
I figured you talk Python, that's good to know (x)! However, if you continue:
>>> t = list(time.localtime()); t[2] -= 1; t[3:6] = [8,0,0]; print time.ctime(time.mktime(t))
Wed Feb 29 08:00:00 2012
>>> t[1] -= 1;
>>> time.ctime(time.mktime(t))
'Tue Jan 31 08:00:00 2012'
So if you have a `t` that is Feb 29, one month ago is Jan 31 or Feb 29, depending on how `t` was constructed.
(x) Edit: I meant, it's good to know about the time module in Python, not that you know Python...
- Erwin 15y agoI don't follow -- the first time which translates to Feb 29th is entered as 0th March. So that underflows to Feb 29th -- the day before March 1st. The second time you have, is 0th February. So that underflows back to the previous day, Jan 31st -- the day before February 1st.
- lysium 15y agoI mean there are two t (0th March and Feb 29th) that print as Feb 29 (so any user seeing the value of those t may rightly assume they are the same), but for one t one month earlier is Jan 31, while for the other t one month earlier is Jan 29. Of course, internally, all is correct, but for the user, things may behave strangely.