Mercurial > emacs
comparison lisp/=diary-lib.el @ 5695:6d93eb3d5bc7
(diary-day-of-year, diary-iso-date, diary-islamic-date,
diary-hebrew-date, diary-julian-date, diary-astro-day-number):
Use new functions from calendar.el.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 30 Jan 1994 00:26:04 +0000 |
parents | 8f055b119428 |
children | 238f508c5256 |
comparison
equal
deleted
inserted
replaced
5694:69471d331d0c | 5695:6d93eb3d5bc7 |
---|---|
1329 "th" | 1329 "th" |
1330 (aref ["th" "st" "nd" "rd"] (% n 10)))) | 1330 (aref ["th" "st" "nd" "rd"] (% n 10)))) |
1331 | 1331 |
1332 (defun diary-day-of-year () | 1332 (defun diary-day-of-year () |
1333 "Day of year and number of days remaining in the year of date diary entry." | 1333 "Day of year and number of days remaining in the year of date diary entry." |
1334 (let* ((year (extract-calendar-year date)) | 1334 (calendar-day-of-year-string date)) |
1335 (day (calendar-day-number date)) | |
1336 (days-remaining (- (calendar-day-number (list 12 31 year)) day))) | |
1337 (format "Day %d of %d; %d day%s remaining in the year" | |
1338 day year days-remaining (if (= days-remaining 1) "" "s")))) | |
1339 | 1335 |
1340 (defun diary-iso-date () | 1336 (defun diary-iso-date () |
1341 "ISO calendar equivalent of date diary entry." | 1337 "ISO calendar equivalent of date diary entry." |
1342 (let ((day (% (calendar-absolute-from-gregorian date) 7)) | 1338 (format "ISO date: %s" (calendar-iso-date-string date))) |
1343 (iso-date (calendar-iso-from-absolute | |
1344 (calendar-absolute-from-gregorian date)))) | |
1345 (format "ISO date: Day %s of week %d of %d." | |
1346 (if (zerop day) 7 day) | |
1347 (extract-calendar-month iso-date) | |
1348 (extract-calendar-year iso-date)))) | |
1349 | 1339 |
1350 (defun diary-islamic-date () | 1340 (defun diary-islamic-date () |
1351 "Islamic calendar equivalent of date diary entry." | 1341 "Islamic calendar equivalent of date diary entry." |
1352 (let* ((i-date (calendar-islamic-from-absolute | 1342 (let ((i (calendar-islamic-date-string |
1353 (calendar-absolute-from-gregorian date))) | 1343 (or (calendar-cursor-to-date) |
1354 (calendar-month-name-array calendar-islamic-month-name-array)) | 1344 (error "Cursor is not on a date!"))))) |
1355 (if (>= (extract-calendar-year i-date) 1) | 1345 (if (string-equal i "") |
1356 (format "Islamic date: %s" (calendar-date-string i-date nil t))))) | 1346 "Date is pre-Islamic" |
1347 (format "Islamic date (until sunset): %s" i)))) | |
1357 | 1348 |
1358 (defun diary-hebrew-date () | 1349 (defun diary-hebrew-date () |
1359 "Hebrew calendar equivalent of date diary entry." | 1350 "Hebrew calendar equivalent of date diary entry." |
1360 (let* ((h-date (calendar-hebrew-from-absolute | 1351 (format "Hebrew date (until sunset): %s" (calendar-hebrew-date-string date))) |
1361 (calendar-absolute-from-gregorian date))) | |
1362 (calendar-month-name-array | |
1363 (if (hebrew-calendar-leap-year-p | |
1364 (extract-calendar-year h-date)) | |
1365 calendar-hebrew-month-name-array-leap-year | |
1366 calendar-hebrew-month-name-array-common-year))) | |
1367 (format "Hebrew date: %s" (calendar-date-string h-date nil t)))) | |
1368 | 1352 |
1369 (defun diary-julian-date () | 1353 (defun diary-julian-date () |
1370 "Julian calendar equivalent of date diary entry." | 1354 "Julian calendar equivalent of date diary entry." |
1371 (format "Julian date: %s" | 1355 (format "Julian date: %s" (calendar-julian-date-string date))) |
1372 (calendar-date-string | |
1373 (calendar-julian-from-absolute | |
1374 (calendar-absolute-from-gregorian date))) | |
1375 nil t)) | |
1376 | 1356 |
1377 (defun diary-astro-day-number () | 1357 (defun diary-astro-day-number () |
1378 "Astronomical (Julian) day number diary entry." | 1358 "Astronomical (Julian) day number diary entry." |
1379 (format "Astronomical (Julian) day number %d" | 1359 (format "Astronomical (Julian) day number %s" |
1380 (+ 1721425 (calendar-absolute-from-gregorian date)))) | 1360 (calendar-astro-date-string date))) |
1381 | 1361 |
1382 (defun diary-omer () | 1362 (defun diary-omer () |
1383 "Omer count diary entry. | 1363 "Omer count diary entry. |
1384 Entry applies if date is within 50 days after Passover." | 1364 Entry applies if date is within 50 days after Passover." |
1385 (let* ((passover | 1365 (let* ((passover |