Datetime shenanigans
Dates are a common source of frustration for programmers and historians. Dates can be missing, incorrect, use inconsistent formats, and they cause lots of bugs.
These entries describe some of the “fun” things I’ve learnt about handling dates.
8 articles
Cleaning up messy dates in JSON
I wrote a Python script to help me get timestamps in a consistent format in my JSON.
Localising the
<time>with JavaScriptI’m using the
<time>element and some JavaScript to display timestamps as human-readable, localised timestamps. Something likeTue, 15 Apr 2025 at 20:45 BSTis easier to read than2025-04-15T19:45:00Z.Preserving Dates during JSON serialisation with vanilla JS
How to make sure you get a
Dateback when you callJSON.parseandJSON.stringify.Have a single definition of “now”
Having one function that you always use to get the current time is super handy when debugging issues that only occur at specific times.
Finding the months between two dates in Python
Showing human-friendly dates in JavaScript
What’s a nicer way to show a date than an ISO 8601 timestamp?
Falsehoods programmers believe about Unix time
It’s not quite the number of seconds since 1 January 1970.
Darwin, pancakes and birthdays
Looking at whether Darwin ever missed out on birthday cake for pancakes
3 notes
Testing date formatting with date-fns-tz and different timezones
Override the
TZenvironment variable in your tests.Remove the microsecond precision from a
datetimein PythonCall
datetime.replace(microsecond=0).There’s a musical that tells you the number of minutes in a year
The song Seasons of Love from Rent starts with the line “Five hundred twenty-five thousand, six hundred minutes”.