branch: master commit dea774811a5a68aad826dae87a7efecedef52ec8 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
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