DEV Community

Zohar Peled
Zohar Peled

Posted on

Why are date and time so surprisingly difficult to work with?

A lot of developers takes a naive approach towards working with DateTime, In this post I will try to warn you about potential pitfalls and things to keep in mind when working with datetime.

In your everyday life, when you think about the date or time, it’s very simple and intuitive – For instance – Today is September 9th 2019, and the time is now 11:57 A.M.
So why is is so hard to write code that correctly use date and time?

Nowadays, a software designed only for a local group of users is rather scarce, so you probably already encountered or going to encounter at least a few of the issues I’m going to write about in this post.

There are several reasons for this difficulty, (almost) each one of them is enough to make it hard on it’s own, and combining all of them together makes it even harder. Here’s a (probably partial) list of them:

  • Culture-dependent calendars.
  • Culture-dependent string representations
  • Time zones
  • Daylight savings time
  • Historical calendar changes
  • Political issues

For a more detailed explanation, visit the original post over on my blog.

Top comments (0)