Skip to content

Instantly share code, notes, and snippets.

@5263
Last active December 12, 2015 10:08
Show Gist options
  • Save 5263/4756848 to your computer and use it in GitHub Desktop.
Save 5263/4756848 to your computer and use it in GitHub Desktop.
Date/Time Group
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