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

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

[elpa] master dea7748 39/46: tiny.el (tiny-date): improve


From: Oleh Krehel
Subject: [elpa] master dea7748 39/46: tiny.el (tiny-date): improve
Date: Sun, 22 Mar 2015 17:42:38 +0000

branch: master
commit dea774811a5a68aad826dae87a7efecedef52ec8
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    tiny.el (tiny-date): improve
    
    * tiny.el (tiny-date): Will recognize e.g. "Mon" and "Mon 10:00" and
      format appropriately.
---
 tiny.el |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/tiny.el b/tiny.el
index 339389c..4d95438 100644
--- a/tiny.el
+++ b/tiny.el
@@ -391,13 +391,19 @@ Return nil if nothing was matched, otherwise
   "Return date representation of S.
 `org-mode' format is used.
 Optional SHIFT argument is the integer amount of days to shift."
-  (let ((time (apply 'encode-time
-                     (org-read-date-analyze
-                      s nil
-                      (decode-time (current-time))))))
+  (let* ((ct (decode-time (current-time)))
+         (time (apply 'encode-time
+                      (org-read-date-analyze
+                       s nil
+                       ct)))
+         (formatter
+          (if (equal (cl-subseq ct 1 3)
+                     (cl-subseq (decode-time time) 1 3))
+              "%Y-%m-%d %a"
+            "%Y-%m-%d %a %H:%M")))
     (when shift
       (setq time (time-add time (days-to-time shift))))
-    (format-time-string "%Y-%m-%d %a" time)))
+    (format-time-string formatter time)))
 
 (provide 'tiny)
 ;;; tiny.el ends here



reply via email to

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