Created
October 5, 2016 11:29
-
-
Save dulek/3d5509a6029830cce9d9da63f9c28983 to your computer and use it in GitHub Desktop.
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
#!/bin/python | |
import argparse | |
from datetime import datetime | |
from pytz import common_timezones, timezone | |
parser = argparse.ArgumentParser(description="Tells you if it's Thursday " | |
"anywhere in the world.") | |
parser.add_argument('--all', action='store_true', default=False, | |
help='Print all timezones with Thursday.') | |
args = parser.parse_args() | |
show_all = args.all | |
all_tzs = [] | |
for tz in common_timezones: | |
date = | |
timezone('Europe/Warsaw').localize(datetime.now()).astimezone(timezone(tz)) | |
if date.weekday() == 3: | |
if not show_all: | |
print "YES, in %s!" % tz | |
break | |
else: | |
all_tzs.append(tz) | |
else: | |
if not all_tzs: | |
print "NO!" | |
else: | |
print "YES, in:\n%s!" % "\n".join(all_tzs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment