emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/why-this 624e98bc78 23/59: Fix relative time calculation


From: ELPA Syncer
Subject: [nongnu] elpa/why-this 624e98bc78 23/59: Fix relative time calculation
Date: Sun, 27 Nov 2022 16:02:50 -0500 (EST)

branch: elpa/why-this
commit 624e98bc78f3ae55215d615c2df9def60fa72dd1
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>

    Fix relative time calculation
---
 why-this.el | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/why-this.el b/why-this.el
index be5a1c9cea..e707e11536 100644
--- a/why-this.el
+++ b/why-this.el
@@ -177,10 +177,13 @@ When EXACT is non-nil, be as exact as possible."
               (setq str (concat str
                                 (unless (zerop count)
                                   (if (eq count 1)
-                                      (format "a%s %s "
-                                              (if (string= type "hour")
-                                                  "n" "")
-                                              type)
+                                      (if (and (not exact)
+                                               (string= type "day"))
+                                          "Yesterday"
+                                        (format "A%s %s "
+                                                (if (string= type "hour")
+                                                    "n" "")
+                                                type))
                                     (format "%i %ss " count type))))
                     elapsed (% elapsed length))))))
     (if (zerop elapsed)
@@ -196,7 +199,9 @@ When EXACT is non-nil, be as exact as possible."
               (funcall calc-time "minute" 60)
               (when (or exact (zerop (length str)))
                 (funcall calc-time "second" 1))))))
-      (concat str "ago"))))
+      (if (and (not exact) (string= str "Yesterday"))
+          str
+        (concat str "ago")))))
 
 (defun why-this-format-data (format data)
   "Format DATA using FORMAT."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]