Make Org future-proof

* lisp/org.el (org-small-year-to-year): Do not hardcode 2037 as the
  last future year for Org.  Always foresee the next 30 years.
This commit is contained in:
Nicolas Goaziou 2014-12-07 00:01:29 +01:00
parent fb906e15d7
commit f212f7cf0d
1 changed files with 9 additions and 8 deletions

View File

@ -17456,14 +17456,15 @@ The variable `date' is bound by the calendar when this is called."
(defun org-small-year-to-year (year)
"Convert 2-digit years into 4-digit years.
38-99 are mapped into 1938-1999. 1-37 are mapped into 2001-2037.
The year 2000 cannot be abbreviated. Any year larger than 99
is returned unchanged."
(if (< year 38)
(setq year (+ 2000 year))
(if (< year 100)
(setq year (+ 1900 year))))
year)
YEAR is expanded into one of the 30 next years, if possible, or
into a past one. Any year larger than 99 is returned unchanged."
(if (>= year 100) year
(let* ((current (string-to-number (format-time-string "%Y" (current-time))))
(century (/ current 100))
(offset (- year (% current 100))))
(cond ((> offset 30) (+ (* (1- century) 100) year))
((> offset -70) (+ (* century 100) year))
(t (+ (* (1+ century) 100) year))))))
(defun org-time-from-absolute (d)
"Return the time corresponding to date D.