Created
November 21, 2014 19:45
-
-
Save mlissner/deda9a7ec0726704a8e5 to your computer and use it in GitHub Desktop.
An attempt at nuking strftime in Django. Alas it also breaks Django.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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