4 ms·
> If I create a date object of 1970-01-01T00:00:00 and repeatedly add 86400 seconds, should I not end up with a date/time that is no longer midnight? Of course
by bartvk 5y ago
> If I create a date object of 1970-01-01T00:00:00 and repeatedly add 86400 seconds, should I not end up with a date/time that is no longer midnight?
Of course and that’s why you shouldn’t do that. I don’t know about other languages, but if you want to advance a certain number of days, you don’t just add seconds. Any code review would pick that apart.
You add (or subtract) date components, meaning you specify a day, week or whatever unit.
Do I misunderstand the question?
- sporkle-feet 5y agoIf we were taking leap seconds into account, we should end up with a date/time that is not midnight. Because it does always remain midnight, it shows we are all ignoring leap seconds.
- sla29970 5y ago"ignoring leap seconds" is equivalent to "using a time scale that does not conform to UTC". Time scales other than UTC have 86400 seconds in a day. UTC is the exception.
- dismantlethesun 5y ago> I don’t know about other languages... Other programming languages apart from what? You never specified which language you're talking about.
- bartvk 5y agoOof I somehow butchered that. Swift.