Article 4YAKV Representative Line: A Short Year

Representative Line: A Short Year

by
Remy Porter
from The Daily WTF on (#4YAKV)

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, ."

proget-icon.png [Advertisement] ProGet can centralize your organization's software applications and components to provide uniform access to developers and servers. Check it out! TheDailyWtf?d=yIl2AUoC8zArTVgg0XvtoU
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments