diff options
| author | Glenn Morris | 2008-03-07 05:13:00 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-03-07 05:13:00 +0000 |
| commit | ec1ee609ae6e8668b3e242ed646d6016368eac4d (patch) | |
| tree | 1b26416e5ecd01ff6d00f0cde4c1fbd0d17bed8d | |
| parent | c4632735bb2fb1c97aab9847bf0bdda2437b08c0 (diff) | |
| download | emacs-ec1ee609ae6e8668b3e242ed646d6016368eac4d.tar.gz emacs-ec1ee609ae6e8668b3e242ed646d6016368eac4d.zip | |
(calendar-dst): New custom group.
(calendar-daylight-savings-starts, calendar-daylight-savings-ends)
(calendar-time-zone, calendar-daylight-time-offset)
(calendar-standard-time-zone-name, calendar-daylight-time-zone-name)
(calendar-daylight-savings-starts-time)
(calendar-daylight-savings-ends-time): Convert from defvar to defcustom.
(calendar-daylight-savings-starts, calendar-daylight-savings-ends):
Move to start.
| -rw-r--r-- | lisp/calendar/cal-dst.el | 156 |
1 files changed, 88 insertions, 68 deletions
diff --git a/lisp/calendar/cal-dst.el b/lisp/calendar/cal-dst.el index 4f442c075f0..a6e9aa252ad 100644 --- a/lisp/calendar/cal-dst.el +++ b/lisp/calendar/cal-dst.el | |||
| @@ -36,6 +36,13 @@ | |||
| 36 | (require 'calendar) | 36 | (require 'calendar) |
| 37 | (require 'cal-persia) | 37 | (require 'cal-persia) |
| 38 | 38 | ||
| 39 | |||
| 40 | (defgroup calendar-dst nil | ||
| 41 | "Options related to Daylight Saving Time." | ||
| 42 | :prefix "calendar-" | ||
| 43 | :group 'calendar) | ||
| 44 | |||
| 45 | |||
| 39 | (defcustom calendar-dst-check-each-year-flag t | 46 | (defcustom calendar-dst-check-each-year-flag t |
| 40 | "Non-nil means to check each year for DST transitions as needed. | 47 | "Non-nil means to check each year for DST transitions as needed. |
| 41 | Otherwise assume the next two transitions found after the | 48 | Otherwise assume the next two transitions found after the |
| @@ -46,9 +53,51 @@ change." | |||
| 46 | :version "22.1" | 53 | :version "22.1" |
| 47 | :group 'calendar) | 54 | :group 'calendar) |
| 48 | 55 | ||
| 56 | ;;;###autoload | ||
| 57 | (put 'calendar-daylight-savings-starts 'risky-local-variable t) | ||
| 58 | (defcustom calendar-daylight-savings-starts '(calendar-dst-starts year) | ||
| 59 | "Sexp giving the date on which daylight saving time starts. | ||
| 60 | This is an expression in the variable `year' whose value gives the Gregorian | ||
| 61 | date in the form (month day year) on which daylight saving time starts. It is | ||
| 62 | used to determine the starting date of daylight saving time for the holiday | ||
| 63 | list and for correcting times of day in the solar and lunar calculations. | ||
| 64 | |||
| 65 | For example, if daylight saving time is mandated to start on October 1, | ||
| 66 | you would set `calendar-daylight-savings-starts' to | ||
| 67 | |||
| 68 | '(10 1 year) | ||
| 69 | |||
| 70 | If it starts on the first Sunday in April, you would set it to | ||
| 71 | |||
| 72 | '(calendar-nth-named-day 1 0 4 year) | ||
| 73 | |||
| 74 | If the locale never uses daylight saving time, set this to nil." | ||
| 75 | :type 'sexp | ||
| 76 | :group 'calendar-dst) | ||
| 77 | |||
| 78 | ;;;###autoload | ||
| 79 | (put 'calendar-daylight-savings-ends 'risky-local-variable t) | ||
| 80 | (defcustom calendar-daylight-savings-ends '(calendar-dst-ends year) | ||
| 81 | "Sexp giving the date on which daylight saving time ends. | ||
| 82 | This is an expression in the variable `year' whose value gives the Gregorian | ||
| 83 | date in the form (month day year) on which daylight saving time ends. It is | ||
| 84 | used to determine the starting date of daylight saving time for the holiday | ||
| 85 | list and for correcting times of day in the solar and lunar calculations. | ||
| 86 | |||
| 87 | For example, if daylight saving time ends on the last Sunday in October: | ||
| 88 | |||
| 89 | '(calendar-nth-named-day -1 0 10 year) | ||
| 90 | |||
| 91 | If the locale never uses daylight saving time, set this to nil." | ||
| 92 | :type 'sexp | ||
| 93 | :group 'calendar-dst) | ||
| 94 | |||
| 95 | ;;; More defcustoms below. | ||
| 96 | |||
| 97 | |||
| 49 | (defvar calendar-current-time-zone-cache nil | 98 | (defvar calendar-current-time-zone-cache nil |
| 50 | "Cache for result of `calendar-current-time-zone'.") | 99 | "Cache for result of `calendar-current-time-zone'.") |
| 51 | (put 'calendar-current-time-zone-cache 'risky-local-variable t) | 100 | (put 'calendar-current-time-zone-cache 'risky-local-variable t) ; why? |
| 52 | 101 | ||
| 53 | (defvar calendar-system-time-basis | 102 | (defvar calendar-system-time-basis |
| 54 | (calendar-absolute-from-gregorian '(1 1 1970)) | 103 | (calendar-absolute-from-gregorian '(1 1 1970)) |
| @@ -310,35 +359,53 @@ it can't find." | |||
| 310 | (unless calendar-current-time-zone-cache | 359 | (unless calendar-current-time-zone-cache |
| 311 | (setq calendar-current-time-zone-cache (calendar-dst-find-data)))) | 360 | (setq calendar-current-time-zone-cache (calendar-dst-find-data)))) |
| 312 | 361 | ||
| 313 | ;;; The following eight defvars relating to daylight saving time should NOT be | 362 | |
| 314 | ;;; marked to go into loaddefs.el where they would be evaluated when Emacs is | 363 | ;; Following options should be set based on conditions when the code |
| 315 | ;;; dumped. These variables' appropriate values depend on the conditions under | 364 | ;; is invoked, so are not suitable for dumping into loaddefs.el. They |
| 316 | ;;; which the code is INVOKED; so it's inappropriate to initialize them when | 365 | ;; default to US Eastern time if time zone info is not available. |
| 317 | ;;; Emacs is dumped---they should be initialized when calendar.el is loaded. | ||
| 318 | ;;; They default to US Eastern time if time zone info is not available. | ||
| 319 | 366 | ||
| 320 | (calendar-current-time-zone) | 367 | (calendar-current-time-zone) |
| 321 | 368 | ||
| 322 | (defvar calendar-time-zone (or (car calendar-current-time-zone-cache) -300) | 369 | (defcustom calendar-time-zone (or (car calendar-current-time-zone-cache) -300) |
| 323 | "*Number of minutes difference between local standard time at | 370 | "Number of minutes difference between local standard time at |
| 324 | `calendar-location-name' and Coordinated Universal (Greenwich) Time. For | 371 | `calendar-location-name' and Coordinated Universal (Greenwich) Time. |
| 325 | example, -300 for New York City, -480 for Los Angeles.") | 372 | For example, -300 for New York City, -480 for Los Angeles." |
| 373 | :type 'integer | ||
| 374 | :group 'calendar-dst) | ||
| 326 | 375 | ||
| 327 | (defvar calendar-daylight-time-offset | 376 | (defcustom calendar-daylight-time-offset |
| 328 | (or (car (cdr calendar-current-time-zone-cache)) 60) | 377 | (or (car (cdr calendar-current-time-zone-cache)) 60) |
| 329 | "*Number of minutes difference between daylight saving and standard time. | 378 | "Number of minutes difference between daylight saving and standard time. |
| 330 | 379 | If the locale never uses daylight saving time, set this to 0." | |
| 331 | If the locale never uses daylight saving time, set this to 0.") | 380 | :type 'integer |
| 381 | :group 'calendar-dst) | ||
| 332 | 382 | ||
| 333 | (defvar calendar-standard-time-zone-name | 383 | (defcustom calendar-standard-time-zone-name |
| 334 | (or (car (nthcdr 2 calendar-current-time-zone-cache)) "EST") | 384 | (or (car (nthcdr 2 calendar-current-time-zone-cache)) "EST") |
| 335 | "*Abbreviated name of standard time zone at `calendar-location-name'. | 385 | "Abbreviated name of standard time zone at `calendar-location-name'. |
| 336 | For example, \"EST\" in New York City, \"PST\" for Los Angeles.") | 386 | For example, \"EST\" in New York City, \"PST\" for Los Angeles." |
| 387 | :type 'string | ||
| 388 | :group 'calendar-dst) | ||
| 337 | 389 | ||
| 338 | (defvar calendar-daylight-time-zone-name | 390 | (defcustom calendar-daylight-time-zone-name |
| 339 | (or (car (nthcdr 3 calendar-current-time-zone-cache)) "EDT") | 391 | (or (car (nthcdr 3 calendar-current-time-zone-cache)) "EDT") |
| 340 | "*Abbreviated name of daylight saving time zone at `calendar-location-name'. | 392 | "Abbreviated name of daylight saving time zone at `calendar-location-name'. |
| 341 | For example, \"EDT\" in New York City, \"PDT\" for Los Angeles.") | 393 | For example, \"EDT\" in New York City, \"PDT\" for Los Angeles." |
| 394 | :type 'string | ||
| 395 | :group 'calendar-dst) | ||
| 396 | |||
| 397 | (defcustom calendar-daylight-savings-starts-time | ||
| 398 | (or (car (nthcdr 6 calendar-current-time-zone-cache)) 120) | ||
| 399 | "Number of minutes after midnight that daylight saving time starts." | ||
| 400 | :type 'integer | ||
| 401 | :group 'calendar-dst) | ||
| 402 | |||
| 403 | (defcustom calendar-daylight-savings-ends-time | ||
| 404 | (or (car (nthcdr 7 calendar-current-time-zone-cache)) | ||
| 405 | calendar-daylight-savings-starts-time) | ||
| 406 | "Number of minutes after midnight that daylight saving time ends." | ||
| 407 | :type 'integer | ||
| 408 | :group 'calendar-dst) | ||
| 342 | 409 | ||
| 343 | 410 | ||
| 344 | (defun calendar-dst-starts (year) | 411 | (defun calendar-dst-starts (year) |
| @@ -363,53 +430,6 @@ This function respects the value of `calendar-dst-check-each-year-flag'." | |||
| 363 | (and (not (zerop calendar-daylight-time-offset)) | 430 | (and (not (zerop calendar-daylight-time-offset)) |
| 364 | (calendar-nth-named-day 1 0 11 year)))) | 431 | (calendar-nth-named-day 1 0 11 year)))) |
| 365 | 432 | ||
| 366 | |||
| 367 | ;;;###autoload | ||
| 368 | (put 'calendar-daylight-savings-starts 'risky-local-variable t) | ||
| 369 | (defvar calendar-daylight-savings-starts | ||
| 370 | '(calendar-dst-starts year) | ||
| 371 | "*Sexp giving the date on which daylight saving time starts. | ||
| 372 | This is an expression in the variable `year' whose value gives the Gregorian | ||
| 373 | date in the form (month day year) on which daylight saving time starts. It is | ||
| 374 | used to determine the starting date of daylight saving time for the holiday | ||
| 375 | list and for correcting times of day in the solar and lunar calculations. | ||
| 376 | |||
| 377 | For example, if daylight saving time is mandated to start on October 1, | ||
| 378 | you would set `calendar-daylight-savings-starts' to | ||
| 379 | |||
| 380 | '(10 1 year) | ||
| 381 | |||
| 382 | If it starts on the first Sunday in April, you would set it to | ||
| 383 | |||
| 384 | '(calendar-nth-named-day 1 0 4 year) | ||
| 385 | |||
| 386 | If the locale never uses daylight saving time, set this to nil.") | ||
| 387 | |||
| 388 | ;;;###autoload | ||
| 389 | (put 'calendar-daylight-savings-ends 'risky-local-variable t) | ||
| 390 | (defvar calendar-daylight-savings-ends | ||
| 391 | '(calendar-dst-ends year) | ||
| 392 | "*Sexp giving the date on which daylight saving time ends. | ||
| 393 | This is an expression in the variable `year' whose value gives the Gregorian | ||
| 394 | date in the form (month day year) on which daylight saving time ends. It is | ||
| 395 | used to determine the starting date of daylight saving time for the holiday | ||
| 396 | list and for correcting times of day in the solar and lunar calculations. | ||
| 397 | |||
| 398 | For example, if daylight saving time ends on the last Sunday in October: | ||
| 399 | |||
| 400 | '(calendar-nth-named-day -1 0 10 year) | ||
| 401 | |||
| 402 | If the locale never uses daylight saving time, set this to nil.") | ||
| 403 | |||
| 404 | (defvar calendar-daylight-savings-starts-time | ||
| 405 | (or (car (nthcdr 6 calendar-current-time-zone-cache)) 120) | ||
| 406 | "*Number of minutes after midnight that daylight saving time starts.") | ||
| 407 | |||
| 408 | (defvar calendar-daylight-savings-ends-time | ||
| 409 | (or (car (nthcdr 7 calendar-current-time-zone-cache)) | ||
| 410 | calendar-daylight-savings-starts-time) | ||
| 411 | "*Number of minutes after midnight that daylight saving time ends.") | ||
| 412 | |||
| 413 | (defun dst-in-effect (date) | 433 | (defun dst-in-effect (date) |
| 414 | "True if on absolute DATE daylight saving time is in effect. | 434 | "True if on absolute DATE daylight saving time is in effect. |
| 415 | Fractional part of DATE is local standard time of day." | 435 | Fractional part of DATE is local standard time of day." |