Lets say you want to calculate the duration of a flight. If everything is in the same time zone you simply calculate: landing time - departure time. But now you are traveling from London to Tokyo. You simply can't calculate landingTime-departureTime. You have to use Time Zones. And then you have to check if it's daylight saving time. What happens if the flight departs in summer time but lands in winter time because during the flight, the day light saving switch happens.
In most cases there are Libraries / built in features for this. But while programming you have to think "Are timezones relevant here?".
TLDR: It's very cumbersome.
ETA: Oh, and then there is the scenario when there are different dates. Like when it is January 1st 8pm in Europe, it's already January 2nd in Japan. So you probably have to think about that case as well
Also to add to confusion, he forgot to mention leap seconds and how to handle them, leap years, clock drift, the fact that countries change timezones or date of daylight saving change arbitrarily (with maybe couple of weeks notice) same with leap seconds,... :)
There is just no way to efficiently and correctly deal with time.
Edit: for all c++ devs: this is currently saving my ass :)
Anybody has any idea how to deal with time on microcontrollers and C? :)
When daylight savings time happens, you turn your clocks back/forwards at 2AM on certain days. On the day you turn the clocks back, it is 1AM twice that day. If liquor sales stop at a certain time, what happens when that time happens during daylight savings changeover? On the days that the clock goes forwards, what is 2½ hours after midnight? 2:30am? but that doesn't exist, so it should be 3:30am.
Someone wants to sell a share of stock at 2pm (where they are). It is 4pm where you are. Can you buy it? Did it go on sale 2 hours ago? Did it go on sale a minute ago? This is why computers use UTC to store time (or they do if their programmers have any brains).
1
u/wallawalla_ Feb 09 '18
eli5, what's the big deal with timezones and programming?