Last active
October 27, 2021 16:53
-
-
Save tacaswell/bc18b8cc4acc9b8e41f1bf1a4bd926de to your computer and use it in GitHub Desktop.
What time is it where your friends are?
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
#! /usr/bin/env python3 | |
_facilities = { | |
"SLAC/ALS": "America/Los_Angeles", | |
"APS": "America/Chicago", | |
"NSLS-II": "America/New_York", | |
"DLS": "Europe/London", | |
"MAXIV": "Europe/Paris", | |
"SLS": "Europe/Paris", | |
"ESRF/SOLIEL": "Europe/Paris", | |
"EU-XFEL": "Europe/Berlin", | |
"S8": "Asia/Tokyo", | |
"PLS/PAL": "Asia/Seoul", | |
"AS": "Australia/Melbourne", | |
} | |
def world_clock(targets, pstring_format="%a %H:%M"): | |
from datetime import datetime | |
from dateutil import tz | |
ct = datetime.now() | |
print(f"{' '*15} {ct.strftime(pstring_format)}") | |
for n, zone in targets.items(): | |
lt = ct.astimezone(tz.gettz(zone)) | |
print( | |
f"{n: <15} {lt.strftime(pstring_format)}" | |
) | |
world_clock(_facilities) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment