Created
February 27, 2024 21:40
-
-
Save dblume/5acc2bd02935c44f1dcd817eff75b88f to your computer and use it in GitHub Desktop.
Unix Timestamps whose lower digits match the clock time's digits too
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 | |
import time | |
# Timestamps whose lower digits are zero when the clock's are too HH:MM:SS "00:00:00" | |
# Eg., 1800000000 = 2027-01-15 00:00:00 | |
million = 1_00_00_00 | |
t = (int(time.time()) // million + 1) * million | |
while time.strftime("%H%M%S", time.localtime(t)) != '000000': | |
t += million | |
print(f'{t} = {time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(t))}') | |
# Timestamps whose lower digits match the clock time's last six digits, whatever they are. | |
# Eg., "143000" in 1711143000 = 2024-03-22 14:30:00 | |
t = (int(time.time()) // 100 + 1) * 100 | |
while time.strftime("%H%M%S", time.localtime(t)) != f'{str(t)[4:]}': | |
t += 100 | |
print(f'{t} = {time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(t))}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment