From 91e5a55fe105570da07bb8011fb7017f58fedb9d Mon Sep 17 00:00:00 2001 From: Diego Zamboni Date: Sat, 7 Dec 2019 20:01:43 +0100 Subject: [PATCH] Updated org-cv-utils--format-time-window If both dates are the same, return only one of them, without the dash. --- org-cv-utils.el | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/org-cv-utils.el b/org-cv-utils.el index 7a972a6..a078ee0 100644 --- a/org-cv-utils.el +++ b/org-cv-utils.el @@ -45,14 +45,19 @@ today => today" date_str)) (defun org-cv-utils--format-time-window (from-date to-date) -"Join date strings in a time window. + "Join date strings in a time window. FROM-DATE -- TO-DATE -in case TO-DATE is nil return Present" - (concat - (org-cv-utils-org-timestamp-to-shortdate from-date) - " -- " - (if (not to-date) "Present" - (org-cv-utils-org-timestamp-to-shortdate to-date)))) +in case TO-DATE is nil return Present. +If both dates are the same, return just FROM-DATE" + (let ((from (when from-date (org-cv-utils-org-timestamp-to-shortdate from-date))) + (to (if (not to-date) "Present" + (org-cv-utils-org-timestamp-to-shortdate to-date)))) + + (if from + (if (string= from to) + from + (concat from " -- " to)) + ""))) (provide 'org-cv-utils) ;;; org-cv-utils ends here