Hi all,

I repeatedly require a string-to-date function, particularly so I can perform integer mathematics on two date stamps. I came up with a neat solution today, during our #imphack-athon, that you might find useful.

I hope it saves you some time next time you need it.

This describes the issue of converting UNIX timestamp to ‘human-readable’

There are leap seconds involved, which will make your calculations off by a tiny bit. That’s why the ‘blindman’ script has the comments about: “optimised for the years 2012 to 2017”. They use UNIX defined timestamps as offsets based on 2012 to 2017.

I’ll be a really old man in 2038, but that’s the year of the UNIX 2038 problem:

Very nice, thanks aron.

@mlseim, you are correct. I index the yearly start times to reduce the leap second issue (for the next 5 years at least) down to 1 second. I am pretty happy with that and it’s pretty trivial to add as many more years onto the array as you like.

As for 2038, I look forward to looking back at this post where I say “that’s someone else’s problem” :slight_smile: