Skip to content

Instantly share code, notes, and snippets.

@komidore64
Last active August 4, 2023 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save komidore64/73c49a99a04377d8c7114c6fd6f36af3 to your computer and use it in GitHub Desktop.
Save komidore64/73c49a99a04377d8c7114c6fd6f36af3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from datetime import datetime, timedelta
class BeatTime():
def __init__(self):
# Swatch Internet Time uses the time scale of Biel Meantime (BMT),
# which is equivalent to UTC+1.
bmt_now = datetime.utcnow() + timedelta(hours=1)
# Swatch Internet Time is calculated by dividing the number of seconds
# past midnight by the number of seconds contained within one .beat.
self.beat_time = (bmt_now.second + (bmt_now.minute * 60) + (bmt_now.hour * 60 * 60)) / 86.4
def __str__(self):
return "@{:.1f}".format(self.beat_time)
print(BeatTime())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment