Last active
February 19, 2018 14:04
-
-
Save jeyraof/ca61f06b3045eb97f682e57e7216f084 to your computer and use it in GitHub Desktop.
timezone without pytz
This file contains 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
from datetime import tzinfo, timedelta | |
class UTC(tzinfo): | |
def utcoffset(self, dt): | |
return timedelta(seconds=0) | |
def dst(self, dt): | |
return timedelta(seconds=0) | |
def tzname(self, dt): | |
return 'UTC' | |
def __repr__(self): | |
return '<UTC+00:00>' | |
class KST(tzinfo): | |
def utcoffset(self, dt): | |
return timedelta(hours=9) | |
def dst(self, dt): | |
return timedelta(seconds=0) | |
def tzname(self, dt): | |
return 'KST' | |
def __repr__(self): | |
return f'<{self.__class__.__name__}+09:00>' | |
utc = UTC() | |
kst = KST() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment