diff options
| author | Craig Jennings <c@cjennings.net> | 2026-07-11 14:18:02 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-07-11 14:18:02 -0500 |
| commit | 3e7ce01e0d2a5f5c294c7d01cf8862e815147666 (patch) | |
| tree | 42290b3b8e9d7601ce70573b21bfc0d34df99a9a | |
| parent | dba72c4d24059d2cb5a7896ce9ca1ac67e775699 (diff) | |
| download | dotemacs-3e7ce01e0d2a5f5c294c7d01cf8862e815147666.tar.gz dotemacs-3e7ce01e0d2a5f5c294c7d01cf8862e815147666.zip | |
fix(custom-datetime): make sortable-time actually sortable
sortable-time-format was 12-hour with AM/PM ("%I:%M:%S %p %Z"), so "01:00:00 PM" sorted before "09:00:00 AM". I switched it to 24-hour "%H:%M:%S %Z", matching sortable-date-time, and updated the test that asserted the AM/PM output.
| -rw-r--r-- | modules/custom-datetime.el | 2 | ||||
| -rw-r--r-- | tests/test-custom-datetime-all-methods.el | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/modules/custom-datetime.el b/modules/custom-datetime.el index 0528688c..52e8c2b3 100644 --- a/modules/custom-datetime.el +++ b/modules/custom-datetime.el @@ -51,7 +51,7 @@ See `format-time-string' for possible replacements.") ;; ------------------------------- Sortable Time ------------------------------- -(defvar sortable-time-format "%I:%M:%S %p %Z " +(defvar sortable-time-format "%H:%M:%S %Z " "Format string used by `cj/insert-sortable-time'. See `format-time-string' for possible replacements.") diff --git a/tests/test-custom-datetime-all-methods.el b/tests/test-custom-datetime-all-methods.el index 62b421bd..1f31c6c4 100644 --- a/tests/test-custom-datetime-all-methods.el +++ b/tests/test-custom-datetime-all-methods.el @@ -54,9 +54,10 @@ (should (string-match-p "14:30:45" result)))) (ert-deftest test-custom-datetime-all-methods-normal-sortable-time () - "cj/insert-sortable-time should insert time with AM/PM and timezone." + "cj/insert-sortable-time should insert 24-hour time so it sorts lexically." (let ((result (test-datetime--run #'cj/insert-sortable-time))) - (should (string-match-p "02:30:45 PM" result)))) + (should (string-match-p "14:30:45" result)) + (should-not (string-match-p "PM" result)))) (ert-deftest test-custom-datetime-all-methods-normal-readable-time () "cj/insert-readable-time should insert short time with AM/PM." |
