Exercise: 4.15 mile walk.
Welsh phase of the day: Yn well, diolch (Better, thanks)
This is day 732, or 367 as the WriteTogether Counter will say that it is because there is something that you learn when you write software that involves dates and times.
Dates and Times are Hard
Yes it is that simple. You would imagine that they aren't hard but it turns out when it comes to calculations involving dates, times or even worse dates & times, things get tricky.
Dates aren't too hard really as long as you remember that:
- Some years have leap years but not always every 4th year
- If you are dealing with two different locations the date in the other location could be yesterday, today or tomorrow. Plus depending on the time of day, that changes.
Which brings us to time.
"Time is an illusion, lunchtime doubly so"
- Douglas Adams
As long as you are dealing with the same date and the same location / timezone things are easy. As soon as you change one of those things get tricky.
- The time difference between 5pm today and 5pm tomorrow can be 23, 24 or 25 hours depending on whether you are moving from or to summer-time.
- The time difference between 1:30am on two different dates can get tricky, see 1 above
- If you are dealing with different countries time-zones don't always change at the same time.
- Even in the same time zone, some places have summer-time and some don't, even inside the same country (eg: Arizona).
Then you need to deal with servers.
- If your user is in London, but the server is in California. The browser thinks it's 4am. but the server thinks it's 8pm the previous day.
- Then add everything above into the mix. The user may be in British Summer Time and the Server in Pacific Standard Time.
So software engineers you tend to store everything in UTC (AKA: GMT, Zulu, Military Time etc) and then adjust to display things to the user in their local timezone.
But that causes problems too because if you have a 2pm appointment on July 17th it says 2pm on July 17th, and 1pm on Dec 25th. Unless you work out whether daylight sayings was in play at the time (eg: July 17th) and now (eg: Dec 25th) and adjust accordingly.
Then of course daylight savings is never the same twice. Pick two years, nope never the same. Go figure.
Some people wonder why some websites have bugs relating to dates and times, especially when you have to support users from all over the world yet put them all in a streak chart and keep the counts straight.
Engineers don't wonder about this at all, because engineers know.
Dates and Times are Hard