aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1996-12-17 00:19:01 +0000
committerRichard M. Stallman1996-12-17 00:19:01 +0000
commitb89446011788d7def7215126e89fb86b5ca496e2 (patch)
treee61d4ea146ee4d2236f56843d7d356c673b8f943
parent6946129cbe0d00931a668b60f7464b4be89875ee (diff)
downloademacs-b89446011788d7def7215126e89fb86b5ca496e2.tar.gz
emacs-b89446011788d7def7215126e89fb86b5ca496e2.zip
(time-stamp-month-dd-yyyy): Use format-time-string.
(time-stamp-dd/mm/yyyy, time-stamp-mon-dd-yyyy, time-stamp-dd-mon-yy) (time-stamp-yy/mm/dd, time-stamp-yyyy/mm/dd, time-stamp-yyyy-mm-dd) (time-stamp-yymmdd, time-stamp-hh:mm:ss, time-stamp-hhmm): Likewise. (time-stamp-month-numbers, time-stamp-month-full-names): Vars deleted.
-rw-r--r--lisp/time-stamp.el66
1 files changed, 11 insertions, 55 deletions
diff --git a/lisp/time-stamp.el b/lisp/time-stamp.el
index 16da129e2bd..81399aecc3d 100644
--- a/lisp/time-stamp.el
+++ b/lisp/time-stamp.el
@@ -40,7 +40,7 @@
40;; Originally based on the 19 Dec 88 version of 40;; Originally based on the 19 Dec 88 version of
41;; date.el by John Sturdy <mcvax!harlqn.co.uk!jcgs@uunet.uu.net> 41;; date.el by John Sturdy <mcvax!harlqn.co.uk!jcgs@uunet.uu.net>
42;; Version 2, January 1995: replaced functions with %-escapes 42;; Version 2, January 1995: replaced functions with %-escapes
43;; $Id: time-stamp.el,v 1.21 1996/12/13 01:49:23 rms Exp rms $ 43;; $Id: time-stamp.el,v 1.22 1996/12/17 00:14:41 rms Exp rms $
44 44
45;;; Code: 45;;; Code:
46 46
@@ -249,15 +249,6 @@ Do not alter other %-combinations, and do detect %%."
249 (sit-for 1))) 249 (sit-for 1)))
250 (time-stamp-fconcat time-stamp-format " "))))) 250 (time-stamp-fconcat time-stamp-format " ")))))
251 251
252(defconst time-stamp-month-numbers
253 '(("Jan" . 1) ("Feb" . 2) ("Mar" . 3) ("Apr" . 4) ("May" . 5) ("Jun" . 6)
254 ("Jul" . 7) ("Aug" . 8) ("Sep" . 9) ("Oct" . 10) ("Nov" . 11) ("Dec" . 12))
255 "Alist of months and their number.")
256
257(defconst time-stamp-month-full-names
258 ["(zero)" "January" "February" "March" "April" "May" "June"
259 "July" "August" "September" "October" "November" "December"])
260
261(defconst time-stamp-no-file "(no file)" 252(defconst time-stamp-no-file "(no file)"
262 "String to use when the buffer is not associated with a file.") 253 "String to use when the buffer is not associated with a file.")
263 254
@@ -305,89 +296,54 @@ around literals."
305 296
306(defun time-stamp-month-dd-yyyy () 297(defun time-stamp-month-dd-yyyy ()
307 "Return the current date as a string in \"Month DD, YYYY\" form." 298 "Return the current date as a string in \"Month DD, YYYY\" form."
308 (let ((date (current-time-string))) 299 (format-time-string "%B %e, %Y"))
309 (format "%s %d, %s"
310 (aref time-stamp-month-full-names
311 (cdr (assoc (substring date 4 7) time-stamp-month-numbers)))
312 (string-to-int (substring date 8 10))
313 (substring date -4))))
314 300
315(defun time-stamp-dd/mm/yyyy () 301(defun time-stamp-dd/mm/yyyy ()
316 "Return the current date as a string in \"DD/MM/YYYY\" form." 302 "Return the current date as a string in \"DD/MM/YYYY\" form."
317 (let ((date (current-time-string))) 303 (format-time-string "%d/%m/%Y"))
318 (format "%02d/%02d/%s"
319 (string-to-int (substring date 8 10))
320 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))
321 (substring date -4) )))
322 304
323;;; same as __DATE__ in ANSI C 305;;; same as __DATE__ in ANSI C
324 306
325(defun time-stamp-mon-dd-yyyy () 307(defun time-stamp-mon-dd-yyyy ()
326 "Return the current date as a string in \"Mon DD YYYY\" form. 308 "Return the current date as a string in \"Mon DD YYYY\" form.
327The first character of DD is space if the value is less than 10." 309The first character of DD is space if the value is less than 10."
328 (let ((date (current-time-string))) 310 (format-time-string "%b %d %Y"))
329 (format "%s %2d %s"
330 (substring date 4 7)
331 (string-to-int (substring date 8 10))
332 (substring date -4))))
333 311
334;;; RFC 822 date 312;;; RFC 822 date
335 313
336(defun time-stamp-dd-mon-yy () 314(defun time-stamp-dd-mon-yy ()
337 "Return the current date as a string in \"DD Mon YY\" form." 315 "Return the current date as a string in \"DD Mon YY\" form."
338 (let ((date (current-time-string))) 316 (format-time-string "%d %b %y"))
339 (format "%02d %s %s"
340 (string-to-int (substring date 8 10))
341 (substring date 4 7)
342 (substring date -2))))
343 317
344;;; RCS 3 date 318;;; RCS 3 date
345 319
346(defun time-stamp-yy/mm/dd () 320(defun time-stamp-yy/mm/dd ()
347 "Return the current date as a string in \"YY/MM/DD\" form." 321 "Return the current date as a string in \"YY/MM/DD\" form."
348 (let ((date (current-time-string))) 322 (format-time-string "%y/%m/%d"))
349 (format "%s/%02d/%02d"
350 (substring date -2)
351 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))
352 (string-to-int (substring date 8 10)))))
353 323
354;;; RCS 5 date 324;;; RCS 5 date
355 325
356(defun time-stamp-yyyy/mm/dd () 326(defun time-stamp-yyyy/mm/dd ()
357 "Return the current date as a string in \"YYYY/MM/DD\" form." 327 "Return the current date as a string in \"YYYY/MM/DD\" form."
358 (let ((date (current-time-string))) 328 (format-time-string "%Y/%m/%d"))
359 (format "%s/%02d/%02d"
360 (substring date -4)
361 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))
362 (string-to-int (substring date 8 10)))))
363 329
364;;; ISO 8601 date 330;;; ISO 8601 date
365 331
366(defun time-stamp-yyyy-mm-dd () 332(defun time-stamp-yyyy-mm-dd ()
367 "Return the current date as a string in \"YYYY-MM-DD\" form." 333 "Return the current date as a string in \"YYYY-MM-DD\" form."
368 (let ((date (current-time-string))) 334 (format-time-string "%Y-%m-%d"))
369 (format "%s-%02d-%02d"
370 (substring date -4)
371 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))
372 (string-to-int (substring date 8 10)))))
373 335
374(defun time-stamp-yymmdd () 336(defun time-stamp-yymmdd ()
375 "Return the current date as a string in \"YYMMDD\" form." 337 "Return the current date as a string in \"YYMMDD\" form."
376 (let ((date (current-time-string))) 338 (format-time-string "%y%m%d"))
377 (format "%s%02d%02d"
378 (substring date -2)
379 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))
380 (string-to-int (substring date 8 10)))))
381 339
382(defun time-stamp-hh:mm:ss () 340(defun time-stamp-hh:mm:ss ()
383 "Return the current time as a string in \"HH:MM:SS\" form." 341 "Return the current time as a string in \"HH:MM:SS\" form."
384 (substring (current-time-string) 11 19)) 342 (format-time-string "%T"))
385 343
386(defun time-stamp-hhmm () 344(defun time-stamp-hhmm ()
387 "Return the current time as a string in \"HHMM\" form." 345 "Return the current time as a string in \"HHMM\" form."
388 (let ((date (current-time-string))) 346 (format-time-string "%H%M"))
389 (concat (substring date 11 13)
390 (substring date 14 16))))
391 347
392(provide 'time-stamp) 348(provide 'time-stamp)
393 349