Last active
December 12, 2015 10:08
-
-
Save 5263/4756848 to your computer and use it in GitHub Desktop.
Date/Time Group
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
def gettimeszonestg(tz,dt1=None): | |
if tz is None: | |
return 'J' | |
else: | |
utco=tz.utcoffset(dt1) | |
if utco.days>=0: | |
tzg = 'ZABCDEFGHIKLM'[utco.seconds//3600] | |
else: | |
tzg = 'ZNOPQRSTUVWXY'[(-utco).seconds//3600] | |
if utco.seconds % 3600 == 1800: | |
tzg += '*' | |
elif utco.seconds % 1800 == 900: | |
tzg += '#' | |
return tzg | |
def dtg(dt1): | |
return dt1.strftime('%d%H%M')+gettimeszonestg(dt1.tzinfo,dt1)+dt1.strftime('%b%y').lower() | |
if __name__ == '__main__': | |
import pytz,datetime,time | |
print dtg(datetime.datetime.now(pytz.timezone(time.tzname[0]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment