I want to write about timestamps. Not because it’s a subject I like, but on the contrary, because it’s a subject I somewhat hate. What is a simple day to day thing for humans is a real source of headaches for programmers.
The list of reasons for that is about as long as the number of permutations programming languages allow you to do while parsing dates with a string format. Just to name a few, symbols can change (“-” vs “/”), order can change, years can either be 4 or 2 digits (probably those born post year 2000 aren’t aware we had a major bug back then), 24 hours vs AM/PM and even locales (English “February” vs French «Février»).
You don’t think it’s a problem? To this date, 18 596 questions bear the tag “datetime” on stackoverflow.com. That’s huge! Still to this date, there are 294 443 questions tagged “c++”. So there are about 15.8 times as many questions for a full language, namely c++, as there are for a what should be a trivial subject: datetime.
Continue reading “Timestamps”