diff options
| author | Jim Blandy | 1993-05-20 06:28:46 +0000 |
|---|---|---|
| committer | Jim Blandy | 1993-05-20 06:28:46 +0000 |
| commit | facb137b9c6bcd0bb91b8b244fe372638b7354fe (patch) | |
| tree | 66affec6fb69d19460bbcd69af8fbb0ef23e6ad3 /lisp | |
| parent | d52c5f5823dc950776f66a2044e861477e974480 (diff) | |
| download | emacs-facb137b9c6bcd0bb91b8b244fe372638b7354fe.tar.gz emacs-facb137b9c6bcd0bb91b8b244fe372638b7354fe.zip | |
Some time-handling patches from Paul Eggert:
* calendar.el (calendar-current-time-zone): New function.
(calendar-time-zone, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name): Use it instead of current-time-zone.
* sendmail.el (mail-do-fcc): Use the same absolute time for both
current-time-string and current-time-zone. Adjust to new format
returned by current-time-zone.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/calendar/calendar.el | 55 | ||||
| -rw-r--r-- | lisp/mail/sendmail.el | 7 |
2 files changed, 56 insertions, 6 deletions
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el index 86098c0a7f7..60c91d72de4 100644 --- a/lisp/calendar/calendar.el +++ b/lisp/calendar/calendar.el | |||
| @@ -479,6 +479,55 @@ For example, -74.0 for New York City.") | |||
| 479 | `calendar-longitude', calendar-latitude'. Default value is just the latitude, | 479 | `calendar-longitude', calendar-latitude'. Default value is just the latitude, |
| 480 | longitude pair.") | 480 | longitude pair.") |
| 481 | 481 | ||
| 482 | (defun calendar-current-time-zone () | ||
| 483 | "Return the offset, savings state, and names for the current time zone. | ||
| 484 | This returns a list of the form (OFFSET SAVINGS-FLAG STANDARD SAVINGS). | ||
| 485 | This list is calculated from a heuristic that is usually correct; | ||
| 486 | to get more reliable results, use current-time-zone. | ||
| 487 | OFFSET is an integer specifying how many minutes east of Greenwich the | ||
| 488 | current time zone is located. A negative value means west of | ||
| 489 | Greenwich. This describes the standard time; if daylight | ||
| 490 | savings time is in effect, it does not affect this value. | ||
| 491 | SAVINGS-FLAG is non-nil iff daylight savings time or some other sort | ||
| 492 | of seasonal time adjustment is in effect. | ||
| 493 | STANDARD is a string giving the name of the time zone when no seasonal | ||
| 494 | time adjustment is in effect. | ||
| 495 | SAVINGS is a string giving the name of the time zone when there is a | ||
| 496 | seasonal time adjustment in effect. | ||
| 497 | If the local area does not use a seasonal time adjustment, | ||
| 498 | SAVINGS-FLAG is always nil, and STANDARD and SAVINGS are equal. | ||
| 499 | |||
| 500 | Some operating systems cannot provide all this information to Emacs; | ||
| 501 | in this case, calendar-current-time-zone returns a list containing nil for | ||
| 502 | the data it can't find." | ||
| 503 | (let* ((quarter-year-seconds 7889238.0) ; # number of seconds in 1/4 year | ||
| 504 | (current-time-arithmetic-base 65536.0) | ||
| 505 | (now (current-time)) | ||
| 506 | (now-zone (current-time-zone now)) | ||
| 507 | (now-offset (car now-zone)) | ||
| 508 | (now-name (car (cdr now-zone))) | ||
| 509 | probe-zone | ||
| 510 | (probe-offset now-offset) | ||
| 511 | (i 0)) | ||
| 512 | ;; Heuristic: probe the time zone offset in the next three calendar | ||
| 513 | ;; quarters, looking for a time zone offset different from now. | ||
| 514 | (while (and (< i 4) (eq now-offset probe-offset)) | ||
| 515 | (let ((probe | ||
| 516 | (list (+ (car now) (round (/ (* i quarter-year-seconds) | ||
| 517 | current-time-arithmetic-base))) | ||
| 518 | 0 0))) | ||
| 519 | (setq probe-zone (current-time-zone probe)) | ||
| 520 | (setq probe-offset (car probe-zone)) | ||
| 521 | (setq i (1+ i)))) | ||
| 522 | (if (or (eq now-offset probe-offset) (not now-offset) (not probe-offset)) | ||
| 523 | (list (and now-offset (/ now-offset 60)) nil now-name now-name) | ||
| 524 | (let ((std-offset (min now-offset probe-offset)) | ||
| 525 | (probe-name (car (cdr probe-zone)))) | ||
| 526 | (list (/ std-offset 60) | ||
| 527 | t | ||
| 528 | (if (eq std-offset now-offset) now-name probe-name) | ||
| 529 | (if (eq std-offset now-offset) probe-name now-name)))))) | ||
| 530 | |||
| 482 | ;;; Since the following three defvars are marked to go into | 531 | ;;; Since the following three defvars are marked to go into |
| 483 | ;;; loaddefs.el, they will be evaluated when Emacs is dumped. | 532 | ;;; loaddefs.el, they will be evaluated when Emacs is dumped. |
| 484 | ;;; However, these variables' appropriate values really depend on the | 533 | ;;; However, these variables' appropriate values really depend on the |
| @@ -497,7 +546,7 @@ If this is nil, it will be set to the local time zone when the calendar | |||
| 497 | package loads.") | 546 | package loads.") |
| 498 | ;;; If the user has given this a real value, don't wipe it out. | 547 | ;;; If the user has given this a real value, don't wipe it out. |
| 499 | (or calendar-time-zone | 548 | (or calendar-time-zone |
| 500 | (setq calendar-time-zone (car (current-time-zone)))) | 549 | (setq calendar-time-zone (car (calendar-current-time-zone)))) |
| 501 | 550 | ||
| 502 | ;;;###autoload | 551 | ;;;###autoload |
| 503 | (defvar calendar-standard-time-zone-name nil | 552 | (defvar calendar-standard-time-zone-name nil |
| @@ -509,7 +558,7 @@ package loads.") | |||
| 509 | ;;; If the user has given this a value, don't wipe it out. | 558 | ;;; If the user has given this a value, don't wipe it out. |
| 510 | (or calendar-standard-time-zone-name | 559 | (or calendar-standard-time-zone-name |
| 511 | (setq calendar-standard-time-zone-name | 560 | (setq calendar-standard-time-zone-name |
| 512 | (car (nthcdr 2 (current-time-zone))))) | 561 | (car (nthcdr 2 (calendar-current-time-zone))))) |
| 513 | 562 | ||
| 514 | ;;;###autoload | 563 | ;;;###autoload |
| 515 | (defvar calendar-daylight-time-zone-name nil | 564 | (defvar calendar-daylight-time-zone-name nil |
| @@ -521,7 +570,7 @@ package loads.") | |||
| 521 | ;;; If the user has given this a value, don't wipe it out. | 570 | ;;; If the user has given this a value, don't wipe it out. |
| 522 | (or calendar-daylight-time-zone-name | 571 | (or calendar-daylight-time-zone-name |
| 523 | (setq calendar-daylight-time-zone-name | 572 | (setq calendar-daylight-time-zone-name |
| 524 | (car (nthcdr 3 (current-time-zone))))) | 573 | (car (nthcdr 3 (calendar-current-time-zone))))) |
| 525 | 574 | ||
| 526 | ;;;###autoload | 575 | ;;;###autoload |
| 527 | (defvar calendar-daylight-savings-starts | 576 | (defvar calendar-daylight-savings-starts |
diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el index 94f6046b44f..e7a6f6f36c2 100644 --- a/lisp/mail/sendmail.el +++ b/lisp/mail/sendmail.el | |||
| @@ -355,6 +355,7 @@ the user from the mailer." | |||
| 355 | (defun mail-do-fcc (header-end) | 355 | (defun mail-do-fcc (header-end) |
| 356 | (let (fcc-list | 356 | (let (fcc-list |
| 357 | (rmailbuf (current-buffer)) | 357 | (rmailbuf (current-buffer)) |
| 358 | (time (current-time)) | ||
| 358 | timezone | 359 | timezone |
| 359 | (tembuf (generate-new-buffer " rmail output")) | 360 | (tembuf (generate-new-buffer " rmail output")) |
| 360 | (case-fold-search t)) | 361 | (case-fold-search t)) |
| @@ -369,8 +370,8 @@ the user from the mailer." | |||
| 369 | fcc-list)) | 370 | fcc-list)) |
| 370 | (delete-region (match-beginning 0) | 371 | (delete-region (match-beginning 0) |
| 371 | (progn (forward-line 1) (point)))) | 372 | (progn (forward-line 1) (point)))) |
| 372 | (let* ((foo (current-time-zone)) | 373 | (let* ((foo (current-time-zone time)) |
| 373 | (offset (+ (car foo) (if (nth 1 foo) 60 0))) | 374 | (offset (if (car foo) (/ (car foo) 60) 0)) |
| 374 | (abs (abs offset))) | 375 | (abs (abs offset))) |
| 375 | (setq timezone (format "%s%02d%02d" | 376 | (setq timezone (format "%s%02d%02d" |
| 376 | (if (< offset 0) "-" "+") | 377 | (if (< offset 0) "-" "+") |
| @@ -379,7 +380,7 @@ the user from the mailer." | |||
| 379 | (set-buffer tembuf) | 380 | (set-buffer tembuf) |
| 380 | (erase-buffer) | 381 | (erase-buffer) |
| 381 | (insert "From " (user-login-name) " " | 382 | (insert "From " (user-login-name) " " |
| 382 | (current-time-string) "\n") | 383 | (current-time-string time) "\n") |
| 383 | ;; Insert the time zone before the year. | 384 | ;; Insert the time zone before the year. |
| 384 | (forward-char -1) | 385 | (forward-char -1) |
| 385 | (forward-word -1) | 386 | (forward-word -1) |