aboutsummaryrefslogtreecommitdiff
path: root/.config/qtile/ordinaldate.py
diff options
context:
space:
mode:
authorJustine Smithies <justine@smithies.me.uk>2023-08-22 19:46:15 +0100
committerJustine Smithies <justine@smithies.me.uk>2023-08-22 19:46:15 +0100
commit6aaea9cf4b283d41016e60735f52c8feb3cd0c9e (patch)
treeffc170bb7f267247b60908ac9125fcc02175afd9 /.config/qtile/ordinaldate.py
parent86c0c3694c93025dfec23f27266905c12f446a4e (diff)
Initial commit
Diffstat (limited to '.config/qtile/ordinaldate.py')
-rw-r--r--.config/qtile/ordinaldate.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/.config/qtile/ordinaldate.py b/.config/qtile/ordinaldate.py
new file mode 100644
index 0000000..3376d62
--- /dev/null
+++ b/.config/qtile/ordinaldate.py
@@ -0,0 +1,20 @@
+# Justine Smithies
+# https://github.com/justinesmithies/qtile-wayland-dotfiles
+
+# Ordinal Date - Displays date in format Friday 11th March 2022 - 14:53
+
+# Add th, nd or st to the date - use custom_date in text box to display
+
+from datetime import datetime as dt
+
+
+def suffix(d):
+ return 'th' if 11 <= d <= 13 else {1: 'st', 2: 'nd', 3: 'rd'}.get(d % 10, 'th')
+
+
+def custom_strftime(format, t):
+ return t.strftime(format).replace('{S}', str(t.day) + suffix(t.day))
+
+
+def custom_date():
+ return custom_strftime('%A {S} %B %Y - %H:%M', dt.now())