Are we sick of of year rollover bugs yet? Well, let’s just agree that people aren’t sick of making these kinds of bugs.
A long time ago, someone at Oleksandr’s company needed to write a Python script that shipped a 4-digit year to a system that only accepted 2-digit years. So 2010
needed to turn into 10
.
They could have used date formatting to format the date into a two digit year, but that involves understanding how to format dates. That just seems like too much overhead, when there’s already a perfectly good way to mangle a string.
year = str(timezone.now().year)
year = year.replace('20', '')
This particular method worked just fine for the vast majority of the 21st century, to date, but mysteriously stopped working on January 1st, 2020. Or, as this script might write the date, “January 1st, .”