Skip to content

Instantly share code, notes, and snippets.

@mlissner
Created November 21, 2014 19:45
Show Gist options
  • Save mlissner/deda9a7ec0726704a8e5 to your computer and use it in GitHub Desktop.
Save mlissner/deda9a7ec0726704a8e5 to your computer and use it in GitHub Desktop.
An attempt at nuking strftime in Django. Alas it also breaks Django.
import datetime
print "Now killing strftime."
class CleanDateTime(datetime.datetime):
def strftime(self, format):
raise NotImplemented(
"Strftime doesn't support dates prior to 1900 and as a "
"consequence CourtListener nukes them from the standard library. "
"We recognize this sucks and is inconvenient, but it beats "
"having your code crash the first time it runs against an old "
"item. You'll live."
)
class CleanDate(datetime.date):
def strftime(self, format):
raise NotImplemented(
"Strftime doesn't support dates prior to 1900 and as a "
"consequence CourtListener nukes them from the standard library. "
"We recognize this sucks and is inconvenient, but it beats "
"having your code crash the first time it runs against an old "
"item. You'll live."
)
datetime.datetime = CleanDateTime
datetime.date = CleanDate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment