summaryrefslogtreecommitdiff
path: root/lisp/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/calendar')
-rw-r--r--lisp/calendar/appt.el4
-rw-r--r--lisp/calendar/cal-hebrew.el2
-rw-r--r--lisp/calendar/cal-iso.el4
-rw-r--r--lisp/calendar/cal-tex.el4
-rw-r--r--lisp/calendar/parse-time.el15
-rw-r--r--lisp/calendar/solar.el4
-rw-r--r--lisp/calendar/time-date.el104
-rw-r--r--lisp/calendar/timeclock.el60
8 files changed, 59 insertions, 138 deletions
diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el
index fff63d3b15c..36ebd2d8812 100644
--- a/lisp/calendar/appt.el
+++ b/lisp/calendar/appt.el
@@ -482,7 +482,9 @@ Usually just deletes the appointment buffer."
(and window
(or (eq window (frame-root-window (window-frame window)))
(delete-window window))))
- (kill-buffer appt-buffer-name)
+ (let ((buffer (get-buffer appt-buffer-name)))
+ (when buffer
+ (kill-buffer buffer)))
(if appt-audible
(beep 1)))
diff --git a/lisp/calendar/cal-hebrew.el b/lisp/calendar/cal-hebrew.el
index acb6368beca..48221439e11 100644
--- a/lisp/calendar/cal-hebrew.el
+++ b/lisp/calendar/cal-hebrew.el
@@ -595,7 +595,7 @@ Hebrew date diary entries must be prefaced by `diary-hebrew-entry-symbol'
of the Hebrew calendar entries, except that the Hebrew month
names cannot be abbreviated. The Hebrew months are numbered
from 1 to 13 with Nisan being 1, 12 being Adar I and 13 being
-Adar II; you must use `Adar I' if you want Adar of a common
+Adar II; you must use \"Adar I\" if you want Adar of a common
Hebrew year. If a Hebrew date diary entry begins with
`diary-nonmarking-symbol', the entry will appear in the diary
listing, but will not be marked in the calendar. This function
diff --git a/lisp/calendar/cal-iso.el b/lisp/calendar/cal-iso.el
index d2680828fe5..d7c9a6d9e95 100644
--- a/lisp/calendar/cal-iso.el
+++ b/lisp/calendar/cal-iso.el
@@ -33,7 +33,7 @@
(defun calendar-iso-to-absolute (date)
"The number of days elapsed between the Gregorian date 12/31/1 BC and DATE.
-The `ISO year' corresponds approximately to the Gregorian year, but
+The \"ISO year\" corresponds approximately to the Gregorian year, but
weeks start on Monday and end on Sunday. The first week of the ISO year is
the first such week in which at least 4 days are in a year. The ISO
commercial DATE has the form (week day year) in which week is in the range
@@ -49,7 +49,7 @@ Sunday). The Gregorian date Sunday, December 31, 1 BC is imaginary."
;;;###cal-autoload
(defun calendar-iso-from-absolute (date)
- "Compute the `ISO commercial date' corresponding to the absolute DATE.
+ "Compute the \"ISO commercial date\" corresponding to the absolute DATE.
The ISO year corresponds approximately to the Gregorian year, but weeks
start on Monday and end on Sunday. The first week of the ISO year is the
first such week in which at least 4 days are in a year. The ISO commercial
diff --git a/lisp/calendar/cal-tex.el b/lisp/calendar/cal-tex.el
index 4f2eb989010..c7729dc9429 100644
--- a/lisp/calendar/cal-tex.el
+++ b/lisp/calendar/cal-tex.el
@@ -1710,8 +1710,8 @@ non-nil, means add to end of buffer without erasing current contents."
(cal-tex-cmd "\\hspace*" space))
(defun cal-tex-comment (&optional comment)
- "Insert `% ', followed by optional string COMMENT, followed by newline.
-COMMENT may contain newlines, which are prefixed by `% ' in the output."
+ "Insert \"% \", followed by optional string COMMENT, followed by newline.
+COMMENT may contain newlines, which are prefixed by \"% \" in the output."
(insert (format "%% %s\n"
(if comment
(replace-regexp-in-string "\n" "\n% " comment)
diff --git a/lisp/calendar/parse-time.el b/lisp/calendar/parse-time.el
index 6ba26a4a00d..b62f9fa7941 100644
--- a/lisp/calendar/parse-time.el
+++ b/lisp/calendar/parse-time.el
@@ -48,7 +48,9 @@
((eq char ?:) ?d)))
(defun parse-time-tokenize (string)
- "Tokenize STRING into substrings."
+ "Tokenize STRING into substrings.
+Each substring is a run of \"valid\" characters, i.e., lowercase
+letters, digits, plus or minus signs or colons."
(let ((start nil)
(end (length string))
(all-digits nil)
@@ -59,7 +61,8 @@
(while (and (< index end) ;Skip invalid characters.
(not (setq c (parse-time-string-chars (aref string index)))))
(cl-incf index))
- (setq start index all-digits (eq c ?0))
+ (setq start index
+ all-digits (eq c ?0))
(while (and (< (cl-incf index) end) ;Scan valid characters.
(setq c (parse-time-string-chars (aref string index))))
(setq all-digits (and all-digits (eq c ?0))))
@@ -143,8 +146,12 @@
;;;###autoload
(defun parse-time-string (string)
"Parse the time-string STRING into (SEC MIN HOUR DAY MON YEAR DOW DST TZ).
-The values are identical to those of `decode-time', but any values that are
-unknown are returned as nil."
+STRING should be on something resembling an RFC2822 string, a la
+\"Fri, 25 Mar 2016 16:24:56 +0100\", but this function is
+somewhat liberal in what format it accepts, and will attempt to
+return a \"likely\" value even for somewhat malformed strings.
+The values returned are identical to those of `decode-time', but
+any values that are unknown are returned as nil."
(let ((time (list nil nil nil nil nil nil nil nil nil))
(temp (parse-time-tokenize (downcase string))))
(while temp
diff --git a/lisp/calendar/solar.el b/lisp/calendar/solar.el
index c78d2bbf519..6fec8055319 100644
--- a/lisp/calendar/solar.el
+++ b/lisp/calendar/solar.el
@@ -65,10 +65,10 @@ and `am-pm' and `time-zone', both alphabetic strings.
For example, the form
- '(24-hours \":\" minutes
+ (24-hours \":\" minutes
(if time-zone \" (\") time-zone (if time-zone \")\"))
-would give military-style times like `21:07 (UTC)'."
+would give military-style times like \"21:07 (UTC)\"."
:type 'sexp
:risky t
:group 'calendar)
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el
index da3e2a267db..a1d946eac74 100644
--- a/lisp/calendar/time-date.el
+++ b/lisp/calendar/time-date.el
@@ -126,16 +126,17 @@ type 2 is (HIGH LOW MICRO), and type 3 is (HIGH LOW MICRO PICO).
For backward compatibility, if only four arguments are given,
it is assumed that PICO was omitted and should be treated as zero."
+ (when (null type)
+ (setq type pico)
+ (setq pico 0))
(cond
((eq type 0) (cons high low))
((eq type 1) (list high low))
((eq type 2) (list high low micro))
- ((eq type 3) (list high low micro pico))
- ((null type) (encode-time-value high low micro 0 pico))))
+ ((eq type 3) (list high low micro pico))))
-(when (and (fboundp 'time-add) (subrp (symbol-function 'time-add)))
- (make-obsolete 'encode-time-value nil "25.1")
- (make-obsolete 'with-decoded-time-value nil "25.1"))
+(make-obsolete 'encode-time-value nil "25.1")
+(make-obsolete 'with-decoded-time-value nil "25.1")
(autoload 'parse-time-string "parse-time")
(autoload 'timezone-make-date-arpa-standard "timezone")
@@ -163,27 +164,8 @@ If DATE lacks timezone information, GMT is assumed."
(apply 'signal err)
(error "Invalid date: %s" date)))))))))
-;; Bit of a mess. Emacs has float-time since at least 21.1.
-;; This file is synced to Gnus, and XEmacs packages may have been written
-;; using time-to-seconds from the Gnus library.
-;;;###autoload(if (or (featurep 'emacs)
-;;;###autoload (and (fboundp 'float-time)
-;;;###autoload (subrp (symbol-function 'float-time))))
-;;;###autoload (defalias 'time-to-seconds 'float-time)
-;;;###autoload (autoload 'time-to-seconds "time-date"))
-
-(eval-when-compile
- (or (featurep 'emacs)
- (and (fboundp 'float-time)
- (subrp (symbol-function 'float-time)))
- (defun time-to-seconds (&optional time)
- "Convert optional value TIME to a floating point number.
-TIME defaults to the current time."
- (with-decoded-time-value ((high low micro pico _type
- (or time (current-time))))
- (+ (* high 65536.0)
- low
- (/ (+ (* micro 1e6) pico) 1e12))))))
+;;;###autoload
+(defalias 'time-to-seconds 'float-time)
;;;###autoload
(defun seconds-to-time (seconds)
@@ -209,68 +191,7 @@ TIME should be either a time value or a date-time string."
(time-subtract nil time))
;;;###autoload
-(defalias 'subtract-time 'time-subtract)
-
-;; These autoloads do nothing in Emacs 25, where the functions are builtin.
-;;;###autoload(autoload 'time-add "time-date")
-;;;###autoload(autoload 'time-subtract "time-date")
-;;;###autoload(autoload 'time-less-p "time-date")
-
-(eval-and-compile
- (when (not (and (fboundp 'time-add) (subrp (symbol-function 'time-add))))
-
- (defun time-add (t1 t2)
- "Add two time values T1 and T2. One should represent a time difference."
- (with-decoded-time-value ((high low micro pico type t1)
- (high2 low2 micro2 pico2 type2 t2))
- (setq high (+ high high2)
- low (+ low low2)
- micro (+ micro micro2)
- pico (+ pico pico2)
- type (max type type2))
- (when (>= pico 1000000)
- (setq micro (1+ micro)
- pico (- pico 1000000)))
- (when (>= micro 1000000)
- (setq low (1+ low)
- micro (- micro 1000000)))
- (when (>= low 65536)
- (setq high (1+ high)
- low (- low 65536)))
- (encode-time-value high low micro pico type)))
-
- (defun time-subtract (t1 t2)
- "Subtract two time values, T1 minus T2.
-Return the difference in the format of a time value."
- (with-decoded-time-value ((high low micro pico type t1)
- (high2 low2 micro2 pico2 type2 t2))
- (setq high (- high high2)
- low (- low low2)
- micro (- micro micro2)
- pico (- pico pico2)
- type (max type type2))
- (when (< pico 0)
- (setq micro (1- micro)
- pico (+ pico 1000000)))
- (when (< micro 0)
- (setq low (1- low)
- micro (+ micro 1000000)))
- (when (< low 0)
- (setq high (1- high)
- low (+ low 65536)))
- (encode-time-value high low micro pico type)))
-
- (defun time-less-p (t1 t2)
- "Return non-nil if time value T1 is earlier than time value T2."
- (with-decoded-time-value ((high1 low1 micro1 pico1 _type1 t1)
- (high2 low2 micro2 pico2 _type2 t2))
- (or (< high1 high2)
- (and (= high1 high2)
- (or (< low1 low2)
- (and (= low1 low2)
- (or (< micro1 micro2)
- (and (= micro1 micro2)
- (< pico1 pico2)))))))))))
+(define-obsolete-function-alias 'subtract-time 'time-subtract "26.1")
;;;###autoload
(defun date-to-day (date)
@@ -324,12 +245,7 @@ The Gregorian date Sunday, December 31, 1bce is imaginary."
(defun time-to-number-of-days (time)
"Return the number of days represented by TIME.
Returns a floating point number."
- (/ (funcall (eval-when-compile
- (if (or (featurep 'emacs)
- (and (fboundp 'float-time)
- (subrp (symbol-function 'float-time))))
- 'float-time
- 'time-to-seconds)) time) (* 60 60 24)))
+ (/ (float-time time) (* 60 60 24)))
;;;###autoload
(defun safe-date-to-time (date)
diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el
index 2bdfd98344a..3d9e2462224 100644
--- a/lisp/calendar/timeclock.el
+++ b/lisp/calendar/timeclock.el
@@ -532,18 +532,17 @@ non-nil, the amount returned will be relative to past time worked."
(message "%s" string)
string)))
-(defalias 'timeclock-time-to-seconds (if (fboundp 'float-time) 'float-time
- 'time-to-seconds))
-
-(defalias 'timeclock-seconds-to-time 'seconds-to-time)
+(define-obsolete-function-alias 'timeclock-time-to-seconds 'float-time "26.1")
+(define-obsolete-function-alias 'timeclock-seconds-to-time 'seconds-to-time
+ "26.1")
;; Should today-only be removed in favor of timeclock-relative? - gm
(defsubst timeclock-when-to-leave (&optional today-only)
"Return a time value representing the end of today's workday.
If TODAY-ONLY is non-nil, the value returned will be relative only to
the time worked today, and not to past time."
- (timeclock-seconds-to-time
- (- (timeclock-time-to-seconds)
+ (seconds-to-time
+ (- (float-time)
(let ((discrep (timeclock-find-discrep)))
(if discrep
(if today-only
@@ -686,9 +685,8 @@ being logged for. Normally only \"in\" events specify a project."
"\n")
(if (equal (downcase code) "o")
(setq timeclock-last-period
- (- (timeclock-time-to-seconds now)
- (timeclock-time-to-seconds
- (cadr timeclock-last-event)))
+ (- (float-time now)
+ (float-time (cadr timeclock-last-event)))
timeclock-discrepancy
(+ timeclock-discrepancy
timeclock-last-period)))
@@ -723,14 +721,14 @@ recorded to disk. If MOMENT is non-nil, use that as the current time.
This is only provided for coherency when used by
`timeclock-discrepancy'."
(if (equal (car timeclock-last-event) "i")
- (- (timeclock-time-to-seconds moment)
- (timeclock-time-to-seconds (cadr timeclock-last-event)))
+ (- (float-time moment)
+ (float-time (cadr timeclock-last-event)))
timeclock-last-period))
(defsubst timeclock-entry-length (entry)
"Return the length of ENTRY in seconds."
- (- (timeclock-time-to-seconds (cadr entry))
- (timeclock-time-to-seconds (car entry))))
+ (- (float-time (cadr entry))
+ (float-time (car entry))))
(defsubst timeclock-entry-begin (entry)
"Return the start time of ENTRY."
@@ -765,8 +763,8 @@ This is only provided for coherency when used by
(defsubst timeclock-entry-list-span (entry-list)
"Return the total time in seconds spanned by ENTRY-LIST."
- (- (timeclock-time-to-seconds (timeclock-entry-list-end entry-list))
- (timeclock-time-to-seconds (timeclock-entry-list-begin entry-list))))
+ (- (float-time (timeclock-entry-list-end entry-list))
+ (float-time (timeclock-entry-list-begin entry-list))))
(defsubst timeclock-entry-list-break (entry-list)
"Return the total break time (span - length) in ENTRY-LIST."
@@ -1137,7 +1135,7 @@ discrepancy, today's discrepancy, and the time worked today."
last-date-limited nil)
(if beg
(error "Error in format of timelog file!")
- (setq beg (timeclock-time-to-seconds (cadr event))))))
+ (setq beg (float-time (cadr event))))))
((equal (downcase (car event)) "o")
(if (and (nth 2 event)
(> (length (nth 2 event)) 0))
@@ -1145,7 +1143,7 @@ discrepancy, today's discrepancy, and the time worked today."
(if (not beg)
(error "Error in format of timelog file!")
(setq timeclock-last-period
- (- (timeclock-time-to-seconds (cadr event)) beg)
+ (- (float-time (cadr event)) beg)
accum (+ timeclock-last-period accum)
beg nil))
(if (equal last-date todays-date)
@@ -1225,8 +1223,8 @@ HTML-P is non-nil, HTML markup is added."
(insert project "</b><br>\n")
(insert project "*\n"))
(let ((proj-data (cdr (assoc project (timeclock-project-alist log))))
- (two-weeks-ago (timeclock-seconds-to-time
- (- (timeclock-time-to-seconds today)
+ (two-weeks-ago (seconds-to-time
+ (- (float-time today)
(* 2 7 24 60 60))))
two-week-len today-len)
(while proj-data
@@ -1278,17 +1276,17 @@ HTML-P is non-nil, HTML markup is added."
<th>-1 year</th>
</tr>")
(let* ((day-list (timeclock-day-list))
- (thirty-days-ago (timeclock-seconds-to-time
- (- (timeclock-time-to-seconds today)
+ (thirty-days-ago (seconds-to-time
+ (- (float-time today)
(* 30 24 60 60))))
- (three-months-ago (timeclock-seconds-to-time
- (- (timeclock-time-to-seconds today)
+ (three-months-ago (seconds-to-time
+ (- (float-time today)
(* 90 24 60 60))))
- (six-months-ago (timeclock-seconds-to-time
- (- (timeclock-time-to-seconds today)
+ (six-months-ago (seconds-to-time
+ (- (float-time today)
(* 180 24 60 60))))
- (one-year-ago (timeclock-seconds-to-time
- (- (timeclock-time-to-seconds today)
+ (one-year-ago (seconds-to-time
+ (- (float-time today)
(* 365 24 60 60))))
(time-in (vector (list t) (list t) (list t) (list t) (list t)))
(time-out (vector (list t) (list t) (list t) (list t) (list t)))
@@ -1303,12 +1301,11 @@ HTML-P is non-nil, HTML markup is added."
(unless (time-less-p
(timeclock-day-begin day)
(aref lengths i))
- (let ((base (timeclock-time-to-seconds
+ (let ((base (float-time
(timeclock-day-base
(timeclock-day-begin day)))))
(nconc (aref time-in i)
- (list (- (timeclock-time-to-seconds
- (timeclock-day-begin day))
+ (list (- (float-time (timeclock-day-begin day))
base)))
(let ((span (timeclock-day-span day))
(len (timeclock-day-length day))
@@ -1320,8 +1317,7 @@ HTML-P is non-nil, HTML markup is added."
(when (and (> span 0)
(> (/ (float len) (float span)) 0.70))
(nconc (aref time-out i)
- (list (- (timeclock-time-to-seconds
- (timeclock-day-end day))
+ (list (- (float-time (timeclock-day-end day))
base)))
(nconc (aref breaks i) (list (- span len))))
(if req