Skip to content

Instantly share code, notes, and snippets.

@asukaminato0721
Created January 19, 2022 17:59
Show Gist options
  • Save asukaminato0721/5bc50014d3cc35cc078efa425145b9ea to your computer and use it in GitHub Desktop.
Save asukaminato0721/5bc50014d3cc35cc078efa425145b9ea to your computer and use it in GitHub Desktop.
A script to remind how time flies.
#!/usr/bin/env python3
from calendar import isleap
from datetime import datetime
from subprocess import Popen
NOW = datetime.now()
YEAR = NOW.year
FIRST_DAY = datetime(YEAR, 1, 1)
DAY_DIFF = (NOW - FIRST_DAY).days + 1
DAY_COUNT = 366 if isleap(YEAR) else 365
Popen(
[
"zenity",
"--list",
"--column=",
"--title=Life is short",
"--width=300",
"--height=500",
"--display=:0.0",
f"""今日是 {NOW.strftime("%Y-%m-%d")}""",
f"""{YEAR} 年第 {DAY_DIFF} 天""",
f"""已过去 {DAY_DIFF / DAY_COUNT:.1%}""",
f"""还剩 {DAY_COUNT - DAY_DIFF} 天""",
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment