r/ProgrammerHumor • • Feb 09 '18

Timezone Support

Post image
31.3k Upvotes

532 comments sorted by

View all comments

Show parent comments

8

u/[deleted] Feb 09 '18 edited Feb 09 '18

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

1

u/wallawalla_ Feb 09 '18

Thanks, that's very informative.

2

u/[deleted] Feb 09 '18

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? :)