File: calendar.el.html

This collection of functions implements a calendar window. It generates a calendar for the current month, together with the previous and coming months, or for any other three-month period. The calendar can be scrolled forward and backward in the window to show months in the past or future; the cursor can move forward and backward by days, weeks, or months, making it possible, for instance, to jump to the date a specified number of days, weeks, or months from the date under the cursor. The user can display a list of holidays and other notable days for the period shown; the notable days can be marked on the calendar, if desired. The user can also specify that dates having corresponding diary entries (in a file that the user specifies) be marked; the diary entries for any date can be viewed in a separate window. The diary and the notable days can be viewed independently of the calendar. Dates can be translated from the (usual) Gregorian calendar to the day of the year/days remaining in year, to the ISO commercial calendar, to the Julian (old style) calendar, to the Hebrew calendar, to the Islamic calendar, to the Bahá’í calendar, to the French Revolutionary calendar, to the Mayan calendar, to the Chinese calendar, to the Coptic calendar, to the Ethiopic calendar, and to the astronomical (Julian) day number. Times of sunrise/sunset can be displayed, as can the phases of the moon. Appointment notification for diary entries is available. Calendar printing via LaTeX is available.

The following files are part of the calendar/diary code:

   appt.el Appointment notification
   cal-bahai.el Bahá’í calendar
   cal-china.el Chinese calendar
   cal-coptic.el Coptic/Ethiopic calendars
   cal-dst.el Daylight saving time rules
   cal-french.el French revolutionary calendar
   cal-hebrew.el Hebrew calendar
   cal-html.el Calendars in HTML
   cal-islam.el Islamic calendar
   cal-iso.el ISO calendar
   cal-julian.el Julian/astronomical calendars
   cal-mayan.el Mayan calendars
   cal-menu.el Menu support
   cal-move.el Movement in the calendar
   cal-persia.el Persian calendar
   cal-tex.el Calendars in LaTeX
   cal-x.el Dedicated frame functions
   calendar.el This file
   diary-lib.el Diary functions
   holidays.el Holiday functions
   lunar.el Phases of the moon
   solar.el Sunrise/sunset, equinoxes/solstices

Technical details of all the calendrical calculations can be found in
"Calendrical Calculations: The Ultimate Edition" by Edward M. Reingold
and Nachum Dershowitz, Cambridge University Press (2018).

An earlier version of the technical details appeared in "Calendrical Calculations" by Nachum Dershowitz and Edward M. Reingold, Software--Practice and Experience, Volume 20, Number 9 (September, 1990), pages 899-928 <https://doi.org/10.1002/spe.4380200905>
<https://pdfs.semanticscholar.org/83b1/14f570002a7a8e1d4e3730cd0e4cdbcad212.pdf>,
and in "Calendrical Calculations, Part II: Three Historical Calendars" by E. M. Reingold, N. Dershowitz, and S. M. Clamen, Software--Practice and Experience, Volume 23, Number 4 (April, 1993), pages 383-404
<https://doi.org/10.1002/spe.4380230404>
<http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.42.6421&rep=rep1&type=pdf>

A note on how dates are represented:

The standard format for a (Gregorian) calendar date in this file is a list of integers (MONTH DAY YEAR) -- see the functions calendar-extract-year, calendar-extract-month, and calendar-extract-day. Internally it also uses an "absolute" format which is an integer number of days since December 31, 1BC on the Gregorian calendar (see e.g. calendar-absolute-from-gregorian), and converts between different calendar scales by converting to and from the absolute format (see e.g. calendar-iso-from-absolute in cal-iso.el). This representation is also useful for certain calculations; e.g. calendar-day-of-week is simply the absolute representation modulo 7, because December 31, 1BC is a Sunday.

A note on free variables:

The calendar passes around a few dynamically bound variables, which unfortunately have rather common names. They are meant to be available for external functions, so the names can't be changed.

displayed-month, displayed-year: bound in calendar-generate, the
  central month of the 3 month calendar window
original-date, number: bound in diary-list-entries, the arguments
  with which that function was called.
date, entry: bound in diary-list-sexp-entries (qv)

Bound in diary-list-entries: diary-entries-list: use in d-l, appt.el, and by diary-add-to-list diary-saved-point: only used in diary-lib.el, passed to the display func date-string: only used in diary-lib.el list-only: don't modify the diary-buffer, just return a list of entries file-glob-attrs: yuck

Defined variables (80)

calendar-abbrev-lengthDefault length of abbreviations to use for day and month names.
calendar-american-date-display-formPseudo-pattern governing the way a date appears in the American style.
calendar-american-month-headerDefault format for calendar month headings with the American date style.
calendar-bahai-all-holidays-flagIf nil, show only major holidays from the Bahá’í calendar.
calendar-bufferName of the buffer used for the calendar.
calendar-chinese-all-holidays-flagIf nil, show only the major holidays from the Chinese calendar.
calendar-christian-all-holidays-flagIf nil, show only major holidays from the Christian calendar.
calendar-column-widthWidth of each day column in the calendar. Minimum value is 3.
calendar-date-display-formPseudo-pattern governing the way a calendar date appears.
calendar-date-echo-textString displayed when the cursor is over a date in the calendar.
calendar-date-styleYour preferred style for writing dates.
calendar-day-abbrev-arrayArray of capitalized strings giving the abbreviated day names.
calendar-day-digit-widthWidth of the day digits in the calendar. Minimum value is 2.
calendar-day-header-arrayArray of strings to use for the headers of the calendar’s day columns.
calendar-day-header-widthWidth of the day column headers in the calendar.
calendar-day-name-arrayArray of capitalized strings giving, in order from Sunday, the day names.
calendar-debug-sexpTurn debugging on when evaluating a sexp in the diary or holiday list.
calendar-european-date-display-formPseudo-pattern governing the way a date appears in the European style.
calendar-european-month-headerDefault format for calendar month headings with the European date style.
calendar-first-date-rowFirst row in the calendar with actual dates.
calendar-hebrew-all-holidays-flagIf nil, show only major holidays from the Hebrew calendar.
calendar-hebrew-yahrzeit-bufferName of the buffer used by ‘calendar-hebrew-list-yahrzeits’.
calendar-holiday-markerHow to mark notable dates in the calendar.
calendar-initial-window-hookList of functions to be called when the calendar window is created.
calendar-intermonth-headerHeader text to display in the space to the left of each calendar month.
calendar-intermonth-spacingSpace between months in the calendar. Minimum value is 1.
calendar-intermonth-textText to display in the space to the left of each calendar month.
calendar-islamic-all-holidays-flagIf nil, show only major holidays from the Islamic calendar.
calendar-iso-date-display-formPseudo-pattern governing the way a date appears in the ISO style.
calendar-iso-month-headerDefault format for calendar month headings with the ISO date style.
calendar-left-marginEmpty space to the left of the first month in the calendar.
calendar-load-hookList of functions to be called after the calendar is first loaded.
calendar-mark-diary-entriesVariable version of the user option ‘calendar-mark-diary-entries-flag’.
calendar-mark-diary-entries-flagNon-nil means mark dates with diary entries, in the calendar window.
calendar-mark-holidaysVariable version of the user option ‘calendar-mark-holidays-flag’.
calendar-mark-holidays-flagNon-nil means mark dates of holidays in the calendar window.
calendar-mark-ringUsed by ‘calendar-set-mark’.
calendar-minimum-window-heightMinimum height ‘calendar-generate-window’ should use for calendar window.
calendar-mode-abbrev-tableAbbrev table for ‘calendar-mode’.
calendar-mode-hookHook run when entering ‘calendar-mode’.
calendar-mode-line-formatIf non-nil, the mode line of the calendar buffer.
calendar-mode-mapKeymap for ‘calendar-mode’.
calendar-mode-syntax-tableSyntax table for ‘calendar-mode’.
calendar-month-abbrev-arrayArray of capitalized strings giving the abbreviated month names.
calendar-month-digit-widthWidth of the region with numbers in each month in the calendar.
calendar-month-edgesAlist of month edge columns.
calendar-month-headerExpression to evaluate to return the calendar month headings.
calendar-month-name-arrayArray of capitalized strings giving, in order, the month names.
calendar-month-widthFull width of each month in the calendar.
calendar-move-hookList of functions called whenever the cursor moves in the calendar.
calendar-offsetThe offset of the principal month from the center of the calendar window.
calendar-other-calendars-bufferName of the buffer used for the display of date on other calendars.
calendar-remove-frame-by-deletingDetermine how the calendar mode removes a frame no longer needed.
calendar-right-marginRight margin of the calendar.
calendar-setupThe frame setup of the calendar.
calendar-split-width-thresholdValue to use for ‘split-width-threshold’ when creating a calendar.
calendar-time-zone-styleYour preferred style for time zones.
calendar-today-invisible-hookList of functions called whenever the current date is not visible.
calendar-today-markerHow to mark today’s date in the calendar.
calendar-today-visible-hookList of functions called whenever the current date is visible.
calendar-view-diary-initially-flagNon-nil means display current date’s diary entries on entry to calendar.
calendar-view-holidays-initially-flagNon-nil means display holidays for current three month period on entry.
calendar-week-start-dayThe day of the week on which a week in the calendar begins.
calendar-weekend-daysDays of the week considered weekend days.
diary-american-date-formsList of pseudo-patterns describing the American style of dates.
diary-bahai-entry-symbolSymbol indicating a diary entry according to the Bahá’í calendar.
diary-chinese-entry-symbolSymbol indicating a diary entry according to the Chinese calendar.
diary-date-formsList of pseudo-patterns describing the forms of date used in the diary.
diary-entry-markerHow to mark dates that have diary entries.
diary-european-date-formsList of pseudo-patterns describing the European style of dates.
diary-fancy-bufferName of the buffer used for the optional fancy display of the diary.
diary-fileName of the file in which one’s personal diary of dates is kept.
diary-hebrew-entry-symbolSymbol indicating a diary entry according to the Hebrew calendar.
diary-islamic-entry-symbolSymbol indicating a diary entry according to the Islamic calendar.
diary-iso-date-formsList of pseudo-patterns describing the ISO style of dates.
diary-nonmarking-symbolSymbol indicating that a diary entry is not to be marked in the calendar.
diary-show-holidays-flagNon-nil means include holidays in the diary display.
holiday-bufferName of the buffer used for the displaying the holidays.
lunar-phases-bufferName of the buffer used for the lunar phases.
solar-sunrises-bufferName of buffer used for sunrise/sunset times.

Defined functions (74)

calendar(&optional ARG)
calendar-abbrev-construct(FULL &optional MAXLEN)
calendar-absolute-from-gregorian(DATE)
calendar-basic-setup(&optional ARG NODISPLAY)
calendar-buffer-list()
calendar-column-to-segment()
calendar-count-days-region()
calendar-current-date(&optional OFFSET)
calendar-cursor-to-date(&optional ERROR EVENT)
calendar-customized-p(SYMBOL)
calendar-date-compare(DATE1 DATE2)
calendar-date-equal(DATE1 DATE2)
calendar-date-is-valid-p(DATE)
calendar-date-is-visible-p(DATE)
calendar-date-string(DATE &optional ABBREVIATE NODAYNAME)
calendar-day-header-construct(&optional WIDTH)
calendar-day-name(DATE &optional ABBREV ABSOLUTE)
calendar-day-number(DATE)
calendar-day-of-week(DATE)
calendar-day-of-year-string(&optional DATE)
calendar-dayname-on-or-before(DAYNAME DATE)
calendar-dlet(BINDERS &rest BODY)
calendar-ensure-newline()
calendar-event-buffer(EVENT)
calendar-exchange-point-and-mark()
calendar-exit(&optional KILL)
calendar-extract-day(DATE)
calendar-extract-month(DATE)
calendar-extract-year(DATE)
calendar-generate(MONTH YEAR)
calendar-generate-month(MONTH YEAR INDENT)
calendar-generate-window(&optional MON YR)
calendar-get-buffer()
calendar-goto-info-node()
calendar-gregorian-from-absolute(DATE)
calendar-in-read-only-buffer(BUFFER &rest BODY)
calendar-increment-month(MON YR N &optional NMONTHS)
calendar-increment-month-cons(N &optional MON YR)
calendar-insert-at-column(INDENT STRING TRUNCATE)
calendar-interval(MON1 YR1 MON2 YR2)
calendar-last-day-of-month(MONTH YEAR)
calendar-leap-year-p(YEAR)
calendar-make-alist(SEQUENCE &optional START-INDEX FILTER &rest SEQUENCES)
calendar-make-temp-face(ATTRLIST)
calendar-mark-today()
calendar-mark-visible-date(DATE &optional MARK)
calendar-mode()
calendar-mode-line-entry(COMMAND ECHO &optional KEY STRING)
calendar-month-edges(SEGMENT)
calendar-month-name(MONTH &optional ABBREV)
calendar-move-to-column(INDENT)
calendar-nongregorian-visible-p(MONTH DAY TOABS FROMABS SWITCH)
calendar-not-implemented()
calendar-nth-named-absday(N DAYNAME MONTH YEAR &optional DAY)
calendar-nth-named-day(N DAYNAME MONTH YEAR &optional DAY)
calendar-other-dates(DATE)
calendar-other-month(MONTH YEAR &optional EVENT)
calendar-print-day-of-year()
calendar-print-other-dates(&optional EVENT)
calendar-read(PROMPT ACCEPTABLE &optional INITIAL-CONTENTS)
calendar-read-date(&optional NODAY DEFAULT-DATE)
calendar-read-sexp(PROMPT PREDICATE &optional DEFAULT &rest ARGS)
calendar-recompute-layout-variables()
calendar-redraw()
calendar-set-date-style(STYLE)
calendar-set-layout-variable(SYMBOL VALUE &optional MINMAX)
calendar-set-mark(ARG &optional EVENT)
calendar-set-mode-line(STR)
calendar-star-date()
calendar-string-spread(STRINGS CHAR LENGTH)
calendar-sum(INDEX INITIAL CONDITION EXPRESSION)
calendar-unmark()
calendar-update-mode-line()
calendar-week-end-day()

Defined faces (6)

calendar-month-headerFace used for month headers in the calendar.
calendar-todayFace for indicating today’s date in the calendar. See the variable ‘calendar-today-marker’.
calendar-weekday-headerFace used for weekday column headers in the calendar. See also the face ‘calendar-weekend-header’.
calendar-weekend-headerFace used for weekend column headers in the calendar. See also the face ‘calendar-weekday-header’.
diaryFace for highlighting diary entries. Used to mark diary entries in the calendar (see ‘diary-entry-marker’), and to highlight the date header in the fancy diary.
holidayFace for indicating in the calendar dates that have holidays. See ‘calendar-holiday-marker’.