Skip to content

Instantly share code, notes, and snippets.

@gryf
Forked from dulek/is-thursday.py
Last active October 12, 2016 08:22
Show Gist options
  • Select an option

  • Save gryf/72bb1d6f09d9ebc5077e2ddd74c32132 to your computer and use it in GitHub Desktop.

Select an option

Save gryf/72bb1d6f09d9ebc5077e2ddd74c32132 to your computer and use it in GitHub Desktop.
#!/usr/bin/env 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.')
show_all = parser.parse_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