Mercurial > emacs
comparison lisp/calendar/calendar.el @ 93091:b801762e0062
(calendar-other-dates): New function.
(calendar-print-other-dates): Use calendar-other-dates.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Thu, 20 Mar 2008 04:41:47 +0000 |
parents | 0e73f340ef25 |
children | c68684b0a2d1 |
comparison
equal
deleted
inserted
replaced
93090:9144c487a567 | 93091:b801762e0062 |
---|---|
2442 (day (calendar-day-number d)) | 2442 (day (calendar-day-number d)) |
2443 (days-remaining (- (calendar-day-number (list 12 31 year)) day))) | 2443 (days-remaining (- (calendar-day-number (list 12 31 year)) day))) |
2444 (format "Day %d of %d; %d day%s remaining in the year" | 2444 (format "Day %d of %d; %d day%s remaining in the year" |
2445 day year days-remaining (if (= days-remaining 1) "" "s")))) | 2445 day year days-remaining (if (= days-remaining 1) "" "s")))) |
2446 | 2446 |
2447 (defun calendar-other-dates (date) | |
2448 "Return a list of strings giving Gregorian DATE in other calendars. | |
2449 DATE is (month day year). Calendars that do not apply are omitted." | |
2450 (let (odate) | |
2451 (delq nil | |
2452 (list | |
2453 (calendar-day-of-year-string date) | |
2454 (format "ISO date: %s" (calendar-iso-date-string date)) | |
2455 (format "Julian date: %s" | |
2456 (calendar-julian-date-string date)) | |
2457 (format "Astronomical (Julian) day number (at noon UTC): %s.0" | |
2458 (calendar-astro-date-string date)) | |
2459 (format "Fixed (RD) date: %s" | |
2460 (calendar-absolute-from-gregorian date)) | |
2461 (format "Hebrew date (before sunset): %s" | |
2462 (calendar-hebrew-date-string date)) | |
2463 (format "Persian date: %s" | |
2464 (calendar-persian-date-string date)) | |
2465 (unless (string-equal | |
2466 (setq odate (calendar-islamic-date-string date)) | |
2467 "") | |
2468 (format "Islamic date (before sunset): %s" odate)) | |
2469 (unless (string-equal | |
2470 (setq odate (calendar-bahai-date-string date)) | |
2471 "") | |
2472 (format "Baha'i date: %s" odate)) | |
2473 (format "Chinese date: %s" | |
2474 (calendar-chinese-date-string date)) | |
2475 (unless (string-equal | |
2476 (setq odate (calendar-coptic-date-string date)) | |
2477 "") | |
2478 (format "Coptic date: %s" odate)) | |
2479 (unless (string-equal | |
2480 (setq odate (calendar-ethiopic-date-string date)) | |
2481 "") | |
2482 (format "Ethiopic date: %s" odate)) | |
2483 (unless (string-equal | |
2484 (setq odate (calendar-french-date-string date)) | |
2485 "") | |
2486 (format "French Revolutionary date: %s" odate)) | |
2487 (format "Mayan date: %s" | |
2488 (calendar-mayan-date-string date)))))) | |
2489 | |
2447 (defun calendar-print-other-dates () | 2490 (defun calendar-print-other-dates () |
2448 "Show dates on other calendars for date under the cursor." | 2491 "Show dates on other calendars for date under the cursor." |
2449 (interactive) | 2492 (interactive) |
2450 (let ((date (calendar-cursor-to-date t)) | 2493 (let ((date (calendar-cursor-to-date t))) |
2451 odate) | |
2452 (calendar-in-read-only-buffer other-calendars-buffer | 2494 (calendar-in-read-only-buffer other-calendars-buffer |
2453 (calendar-set-mode-line (format "%s (Gregorian)" | 2495 (calendar-set-mode-line (format "%s (Gregorian)" |
2454 (calendar-date-string date))) | 2496 (calendar-date-string date))) |
2455 (apply | 2497 (insert (mapconcat 'identity (calendar-other-dates date) "\n"))))) |
2456 'insert | |
2457 (delq nil | |
2458 (list | |
2459 (calendar-day-of-year-string date) "\n" | |
2460 (format "ISO date: %s\n" (calendar-iso-date-string date)) | |
2461 (format "Julian date: %s\n" | |
2462 (calendar-julian-date-string date)) | |
2463 (format "Astronomical (Julian) day number (at noon UTC): %s.0\n" | |
2464 (calendar-astro-date-string date)) | |
2465 (format "Fixed (RD) date: %s\n" | |
2466 (calendar-absolute-from-gregorian date)) | |
2467 (format "Hebrew date (before sunset): %s\n" | |
2468 (calendar-hebrew-date-string date)) | |
2469 (format "Persian date: %s\n" | |
2470 (calendar-persian-date-string date)) | |
2471 (unless (string-equal | |
2472 (setq odate (calendar-islamic-date-string date)) | |
2473 "") | |
2474 (format "Islamic date (before sunset): %s\n" odate)) | |
2475 (unless (string-equal | |
2476 (setq odate (calendar-bahai-date-string date)) | |
2477 "") | |
2478 (format "Baha'i date (before sunset): %s\n" odate)) | |
2479 (format "Chinese date: %s\n" | |
2480 (calendar-chinese-date-string date)) | |
2481 (unless (string-equal | |
2482 (setq odate (calendar-coptic-date-string date)) | |
2483 "") | |
2484 (format "Coptic date: %s\n" odate)) | |
2485 (unless (string-equal | |
2486 (setq odate (calendar-ethiopic-date-string date)) | |
2487 "") | |
2488 (format "Ethiopic date: %s\n" e)) | |
2489 (unless (string-equal | |
2490 (setq odate (calendar-french-date-string date)) | |
2491 "") | |
2492 (format "French Revolutionary date: %s\n" odate)) | |
2493 (format "Mayan date: %s\n" | |
2494 (calendar-mayan-date-string date)))))))) | |
2495 | 2498 |
2496 (defun calendar-print-day-of-year () | 2499 (defun calendar-print-day-of-year () |
2497 "Show day number in year/days remaining in year for date under the cursor." | 2500 "Show day number in year/days remaining in year for date under the cursor." |
2498 (interactive) | 2501 (interactive) |
2499 (message "%s" (calendar-day-of-year-string (calendar-cursor-to-date t)))) | 2502 (message "%s" (calendar-day-of-year-string (calendar-cursor-to-date t)))) |