3 ms·
About #7: doesn't a month always end in the same year it started?
by sp332 14y ago
About #7: doesn't a month always end in the same year it started?
- tomjen3 14y agoWell I guess it is possible if you used some Chinese or Jewish calendar or something like that. But at least in the western system it shouldn't be possible to it to span years.
- stan_rogers 14y agoThe way you're thinking about it, yes -- but the passage of a month may take you from December the [mumbleth] to January the [mumbleth], which are in different years. For some strange reason, code in the wild doesn't always account for that, so the due date for an item may well be eleven months before the request was entered.
- hcarvalhoalves 14y agoI like to call this kind of bug "New Year's Wake-up Call from Hell".
- sses 14y agoOne I caught recently: The difference between the current time and one week from the current time is not always 7 * 86400 seconds. By noticing an automated test that failed 2 weeks out of the year.
- jes5199 14y agoI think every test suite has tests that only fail right around the start and end of daylight savings time.
- NoahSussman 14y agoIf the tests are failing because the production code is confused about daylight savings time, then you may have a serious problem. If on the other hand it's just the test code that's flaky, usually such problems can be alleviated by refactoring such that one passes the time function as a parameter. This is in preference to hard-coding calls to the system time in test, which imho one should never do. Once an arbitrary time function can be passed as a parameter, one can provide a mock or fake system clock for test purposes. Ideally one would still want to test under daylight savings' conditions. But at the least this approach leaves one in a place where one can test the common 24-hours-in-a-day case without having the tests spuriously fail two days out of every year.
- Corvus 14y agoBetween 1582 and 1752 England had two different New Year's Days, January 1 and March 25, used for different purposes. The same day had different years depending on who you were talking to. See http://en.wikipedia.org/wiki/Dual_dating http://en.wikipedia.org/wiki/Dual_dating.