Move to ../etc
[emacs.git] / doc / emacs / calendar.texi
blob16f8ebed427c11a39441ff094e5a0a883825a39e
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
3 @c   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @node Calendar/Diary, Gnus, Dired, Top
6 @chapter The Calendar and the Diary
7 @cindex calendar
8 @findex calendar
10   Emacs provides the functions of a desk calendar, with a diary of
11 planned or past events.  It also has facilities for managing your
12 appointments, and keeping track of how much time you spend working on
13 certain projects.
15   To enter the calendar, type @kbd{M-x calendar}; this displays a
16 three-month calendar centered on the current month, with point on the
17 current date.  With a numeric argument, as in @kbd{C-u M-x calendar}, it
18 prompts you for the month and year to be the center of the three-month
19 calendar.  The calendar uses its own buffer, whose major mode is
20 Calendar mode.
22   @kbd{Mouse-2} in the calendar brings up a menu of operations on a
23 particular date; @kbd{Mouse-3} brings up a menu of commonly used
24 calendar features that are independent of any particular date.  To exit
25 the calendar, type @kbd{q}.
27 @iftex
28   This chapter describes the basic calendar features.
29 @inforef{Advanced Calendar/Diary Usage,, emacs-xtra}, for information
30 about more specialized features.
31 @end iftex
33 @menu
34 * Calendar Motion::     Moving through the calendar; selecting a date.
35 * Scroll Calendar::     Bringing earlier or later months onto the screen.
36 * Counting Days::       How many days are there between two dates?
37 * General Calendar::    Exiting or recomputing the calendar.
38 * Writing Calendar Files:: Writing calendars to files of various formats.
39 * Holidays::            Displaying dates of holidays.
40 * Sunrise/Sunset::      Displaying local times of sunrise and sunset.
41 * Lunar Phases::        Displaying phases of the moon.
42 * Other Calendars::     Converting dates to other calendar systems.
43 * Diary::               Displaying events from your diary.
44 * Appointments::        Reminders when it's time to do something.
45 * Importing Diary::     Converting diary events to/from other formats.
46 * Daylight Saving::     How to specify when daylight saving time is active.
47 * Time Intervals::      Keeping track of time intervals.
48 @ifnottex
49 * Advanced Calendar/Diary Usage:: Advanced Calendar/Diary customization.
50 @end ifnottex
51 @end menu
53 @node Calendar Motion
54 @section Movement in the Calendar
56 @cindex moving inside the calendar
57   Calendar mode provides commands to move through the calendar in
58 logical units of time such as days, weeks, months, and years.  If you
59 move outside the three months originally displayed, the calendar
60 display ``scrolls'' automatically through time to make the selected
61 date visible.  Moving to a date lets you view its holidays or diary
62 entries, or convert it to other calendars; moving by long time periods
63 is also useful simply to scroll the calendar.
65 @menu
66 * Calendar Unit Motion::      Moving by days, weeks, months, and years.
67 * Move to Beginning or End::  Moving to start/end of weeks, months, and years.
68 * Specified Dates::           Moving to the current date or another
69                                 specific date.
70 @end menu
72 @node Calendar Unit Motion
73 @subsection Motion by Standard Lengths of Time
75   The commands for movement in the calendar buffer parallel the
76 commands for movement in text.  You can move forward and backward by
77 days, weeks, months, and years.
79 @table @kbd
80 @item C-f
81 Move point one day forward (@code{calendar-forward-day}).
82 @item C-b
83 Move point one day backward (@code{calendar-backward-day}).
84 @item C-n
85 Move point one week forward (@code{calendar-forward-week}).
86 @item C-p
87 Move point one week backward (@code{calendar-backward-week}).
88 @item M-@}
89 Move point one month forward (@code{calendar-forward-month}).
90 @item M-@{
91 Move point one month backward (@code{calendar-backward-month}).
92 @item C-x ]
93 Move point one year forward (@code{calendar-forward-year}).
94 @item C-x [
95 Move point one year backward (@code{calendar-backward-year}).
96 @end table
98 @kindex C-f @r{(Calendar mode)}
99 @findex calendar-forward-day
100 @kindex C-b @r{(Calendar mode)}
101 @findex calendar-backward-day
102 @kindex C-n @r{(Calendar mode)}
103 @findex calendar-forward-week
104 @kindex C-p @r{(Calendar mode)}
105 @findex calendar-backward-week
106   The day and week commands are natural analogues of the usual Emacs
107 commands for moving by characters and by lines.  Just as @kbd{C-n}
108 usually moves to the same column in the following line, in Calendar
109 mode it moves to the same day in the following week.  And @kbd{C-p}
110 moves to the same day in the previous week.
112   The arrow keys are equivalent to @kbd{C-f}, @kbd{C-b}, @kbd{C-n} and
113 @kbd{C-p}, just as they normally are in other modes.
115 @kindex M-@} @r{(Calendar mode)}
116 @findex calendar-forward-month
117 @kindex M-@{ @r{(Calendar mode)}
118 @findex calendar-backward-month
119 @kindex C-x ] @r{(Calendar mode)}
120 @findex calendar-forward-year
121 @kindex C-x [ @r{(Calendar mode)}
122 @findex calendar-forward-year
123   The commands for motion by months and years work like those for
124 weeks, but move a larger distance.  The month commands @kbd{M-@}} and
125 @kbd{M-@{} move forward or backward by an entire month.  The year
126 commands @kbd{C-x ]} and @w{@kbd{C-x [}} move forward or backward a
127 whole year.
129   The easiest way to remember these commands is to consider months and
130 years analogous to paragraphs and pages of text, respectively.  But
131 the commands themselves are not quite analogous.  The ordinary Emacs
132 paragraph commands move to the beginning or end of a paragraph,
133 whereas these month and year commands move by an entire month or an
134 entire year, keeping the same date within the month or year.
136   All these commands accept a numeric argument as a repeat count.
137 For convenience, the digit keys and the minus sign specify numeric
138 arguments in Calendar mode even without the Meta modifier.  For example,
139 @kbd{100 C-f} moves point 100 days forward from its present location.
141 @node Move to Beginning or End
142 @subsection Beginning or End of Week, Month or Year
144   A week (or month, or year) is not just a quantity of days; we think of
145 weeks (months, years) as starting on particular dates.  So Calendar mode
146 provides commands to move to the beginning or end of a week, month or
147 year:
149 @table @kbd
150 @kindex C-a @r{(Calendar mode)}
151 @findex calendar-beginning-of-week
152 @item C-a
153 Move point to start of week (@code{calendar-beginning-of-week}).
154 @kindex C-e @r{(Calendar mode)}
155 @findex calendar-end-of-week
156 @item C-e
157 Move point to end of week (@code{calendar-end-of-week}).
158 @kindex M-a @r{(Calendar mode)}
159 @findex calendar-beginning-of-month
160 @item M-a
161 Move point to start of month (@code{calendar-beginning-of-month}).
162 @kindex M-e @r{(Calendar mode)}
163 @findex calendar-end-of-month
164 @item M-e
165 Move point to end of month (@code{calendar-end-of-month}).
166 @kindex M-< @r{(Calendar mode)}
167 @findex calendar-beginning-of-year
168 @item M-<
169 Move point to start of year (@code{calendar-beginning-of-year}).
170 @kindex M-> @r{(Calendar mode)}
171 @findex calendar-end-of-year
172 @item M->
173 Move point to end of year (@code{calendar-end-of-year}).
174 @end table
176   These commands also take numeric arguments as repeat counts, with the
177 repeat count indicating how many weeks, months, or years to move
178 backward or forward.
180 @vindex calendar-week-start-day
181 @cindex weeks, which day they start on
182 @cindex calendar, first day of week
183   By default, weeks begin on Sunday.  To make them begin on Monday
184 instead, set the variable @code{calendar-week-start-day} to 1.
186 @node Specified Dates
187 @subsection Specified Dates
189   Calendar mode provides commands for moving to a particular date
190 specified in various ways.
192 @table @kbd
193 @item g d
194 Move point to specified date (@code{calendar-goto-date}).
195 @item g D
196 Move point to specified day of year (@code{calendar-goto-day-of-year}).
197 @item g w
198 Move point to specified week of year (@code{calendar-goto-iso-week}).
199 @item o
200 Center calendar around specified month (@code{calendar-other-month}).
201 @item .
202 Move point to today's date (@code{calendar-goto-today}).
203 @end table
205 @kindex g d @r{(Calendar mode)}
206 @findex calendar-goto-date
207   @kbd{g d} (@code{calendar-goto-date}) prompts for a year, a month, and a day
208 of the month, and then moves to that date.  Because the calendar includes all
209 dates from the beginning of the current era, you must type the year in its
210 entirety; that is, type @samp{1990}, not @samp{90}.
212 @kindex g D @r{(Calendar mode)}
213 @findex calendar-goto-day-of-year
214 @kindex g w @r{(Calendar mode)}
215 @findex calendar-goto-iso-week
216   @kbd{g D} (@code{calendar-goto-day-of-year}) prompts for a year and
217 day number, and moves to that date.  Negative day numbers count
218 backward from the end of the year.  @kbd{g w}
219 (@code{calendar-goto-iso-week}) prompts for a year and week number,
220 and moves to that week.
222 @kindex o @r{(Calendar mode)}
223 @findex calendar-other-month
224   @kbd{o} (@code{calendar-other-month}) prompts for a month and year,
225 then centers the three-month calendar around that month.
227 @kindex . @r{(Calendar mode)}
228 @findex calendar-goto-today
229   You can return to today's date with @kbd{.}@:
230 (@code{calendar-goto-today}).
232 @node Scroll Calendar
233 @section Scrolling in the Calendar
235 @cindex scrolling in the calendar
236   The calendar display scrolls automatically through time when you
237 move out of the visible portion.  You can also scroll it manually.
238 Imagine that the calendar window contains a long strip of paper with
239 the months on it.  Scrolling the calendar means moving the strip
240 horizontally, so that new months become visible in the window.
242 @table @kbd
243 @item >
244 Scroll calendar one month forward (@code{calendar-scroll-left}).
245 @item <
246 Scroll calendar one month backward (@code{calendar-scroll-right}).
247 @item C-v
248 @itemx @key{NEXT}
249 Scroll calendar three months forward
250 (@code{calendar-scroll-left-three-months}).
251 @item M-v
252 @itemx @key{PRIOR}
253 Scroll calendar three months backward
254 (@code{calendar-scroll-right-three-months}).
255 @end table
257 @kindex > @r{(Calendar mode)}
258 @findex calendar-scroll-left
259 @kindex < @r{(Calendar mode)}
260 @findex calendar-scroll-right
261   The most basic calendar scroll commands scroll by one month at a
262 time.  This means that there are two months of overlap between the
263 display before the command and the display after.  @kbd{>} scrolls the
264 calendar contents one month forward in time.  @kbd{<} scrolls the
265 contents one month backwards in time.
267 @kindex C-v @r{(Calendar mode)}
268 @findex calendar-scroll-left-three-months
269 @kindex M-v @r{(Calendar mode)}
270 @findex calendar-scroll-right-three-months
271   The commands @kbd{C-v} and @kbd{M-v} scroll the calendar by an entire
272 ``screenful''---three months---in analogy with the usual meaning of
273 these commands.  @kbd{C-v} makes later dates visible and @kbd{M-v} makes
274 earlier dates visible.  These commands take a numeric argument as a
275 repeat count; in particular, since @kbd{C-u} multiplies the next command
276 by four, typing @kbd{C-u C-v} scrolls the calendar forward by a year and
277 typing @kbd{C-u M-v} scrolls the calendar backward by a year.
279   The function keys @key{NEXT} and @key{PRIOR} are equivalent to
280 @kbd{C-v} and @kbd{M-v}, just as they are in other modes.
282 @node Counting Days
283 @section Counting Days
285 @table @kbd
286 @item M-=
287 Display the number of days in the current region
288 (@code{calendar-count-days-region}).
289 @end table
291 @kindex M-= @r{(Calendar mode)}
292 @findex calendar-count-days-region
293   To determine the number of days in the region, type @kbd{M-=}
294 (@code{calendar-count-days-region}).  The numbers of days shown is
295 @emph{inclusive}; that is, it includes the days specified by mark and
296 point.
298 @node General Calendar
299 @section Miscellaneous Calendar Commands
301 @table @kbd
302 @item p d
303 Display day-in-year (@code{calendar-print-day-of-year}).
304 @item C-c C-l
305 Regenerate the calendar window (@code{calendar-redraw}).
306 @item SPC
307 Scroll the next window up (@code{scroll-other-window}).
308 @item DEL
309 Scroll the next window down (@code{scroll-other-window-down}).
310 @item q
311 Exit from calendar (@code{calendar-exit}).
312 @end table
314 @kindex p d @r{(Calendar mode)}
315 @cindex day of year
316 @findex calendar-print-day-of-year
317   To display the number of days elapsed since the start of the year, or
318 the number of days remaining in the year, type the @kbd{p d} command
319 (@code{calendar-print-day-of-year}).  This displays both of those
320 numbers in the echo area.  The count of days elapsed includes the
321 selected date.  The count of days remaining does not include that
322 date.
324 @kindex C-c C-l @r{(Calendar mode)}
325 @findex calendar-redraw
326   If the calendar window text gets corrupted, type @kbd{C-c C-l}
327 (@code{calendar-redraw}) to redraw it.  (This can only happen if you use
328 non-Calendar-mode editing commands.)
330 @kindex SPC @r{(Calendar mode)}
331   In Calendar mode, you can use @kbd{SPC} (@code{scroll-other-window})
332 and @kbd{DEL} (@code{scroll-other-window-down}) to scroll the other
333 window up or down, respectively.  This is handy when you display a list
334 of holidays or diary entries in another window.
336 @kindex q @r{(Calendar mode)}
337 @findex exit-calendar
338 @vindex calendar-remove-frame-by-deleting
339   To exit from the calendar, type @kbd{q} (@code{calendar-exit}).  This
340 buries all buffers related to the calendar, selecting other buffers.
341 (If a frame contains a dedicated calendar window, exiting from the
342 calendar deletes or iconifies that frame depending on the value of
343 @code{calendar-remove-frame-by-deleting}.)
345 @node Writing Calendar Files
346 @section Writing Calendar Files
348   These packages produce files of various formats containing calendar
349 and diary entries, for display purposes.
351 @cindex calendar and HTML
352   The Calendar HTML commands produce files of HTML code that contain
353 calendar and diary entries.  Each file applies to one month, and has a
354 name of the format @file{@var{yyyy}-@var{mm}.html}, where @var{yyyy} and
355 @var{mm} are the four-digit year and two-digit month, respectively.  The
356 variable @code{cal-html-directory} specifies the default output
357 directory for the HTML files.
359 @vindex cal-html-css-default
360   Diary entries enclosed by @code{<} and @code{>} are interpreted as
361 HTML tags (for example: this is a diary entry with <font
362 color=''red''>some red text</font>).  You can change the overall
363 appearance of the displayed HTML pages (for example, the color of
364 various page elements, header styles) via a stylesheet @file{cal.css} in
365 the directory containing the HTML files (see the value of the variable
366 @code{cal-html-css-default} for relevant style settings).
368 @kindex t @r{(Calendar mode)}
369 @table @kbd
370 @item H m
371 Generate a one-month calendar (@code{cal-html-cursor-month}).
372 @item H y
373 Generate a calendar file for each month of a year, as well as an index
374 page (@code{cal-html-cursor-year}).  By default, this command writes
375 files to a @var{yyyy} subdirectory - if this is altered some hyperlinks
376 between years will not work.
377 @end table
379   If the variable @code{cal-html-print-day-number-flag} is
380 non-@code{nil}, then the monthly calendars show the day-of-the-year
381 number. The variable @code{cal-html-year-index-cols} specifies the
382 number of columns in the yearly index page.
384 @cindex calendar and La@TeX{}
385   The Calendar La@TeX{} commands produce a buffer of La@TeX{} code that
386 prints as a calendar.  Depending on the command you use, the printed
387 calendar covers the day, week, month or year that point is in.
389 @kindex t @r{(Calendar mode)}
390 @table @kbd
391 @item t m
392 Generate a one-month calendar (@code{cal-tex-cursor-month}).
393 @item t M
394 Generate a sideways-printing one-month calendar
395 (@code{cal-tex-cursor-month-landscape}).
396 @item t d
397 Generate a one-day calendar
398 (@code{cal-tex-cursor-day}).
399 @item t w 1
400 Generate a one-page calendar for one week
401 (@code{cal-tex-cursor-week}).
402 @item t w 2
403 Generate a two-page calendar for one week
404 (@code{cal-tex-cursor-week2}).
405 @item t w 3
406 Generate an ISO-style calendar for one week
407 (@code{cal-tex-cursor-week-iso}).
408 @item t w 4
409 Generate a calendar for one Monday-starting week
410 (@code{cal-tex-cursor-week-monday}).
411 @item t f w
412 Generate a Filofax-style two-weeks-at-a-glance calendar
413 (@code{cal-tex-cursor-filofax-2week}).
414 @item t f W
415 Generate a Filofax-style one-week-at-a-glance calendar
416 (@code{cal-tex-cursor-filofax-week}).
417 @item t y
418 Generate a calendar for one year
419 (@code{cal-tex-cursor-year}).
420 @item t Y
421 Generate a sideways-printing calendar for one year
422 (@code{cal-tex-cursor-year-landscape}).
423 @item t f y
424 Generate a Filofax-style calendar for one year
425 (@code{cal-tex-cursor-filofax-year}).
426 @end table
428   Some of these commands print the calendar sideways (in ``landscape
429 mode''), so it can be wider than it is long.  Some of them use Filofax
430 paper size (3.75in x 6.75in).  All of these commands accept a prefix
431 argument which specifies how many days, weeks, months or years to print
432 (starting always with the selected one).
434   If the variable @code{cal-tex-holidays} is non-@code{nil} (the default),
435 then the printed calendars show the holidays in @code{calendar-holidays}.
436 If the variable @code{cal-tex-diary} is non-@code{nil} (the default is
437 @code{nil}), diary entries are included also (in monthly, filofax, and
438 iso-week calendars only).  If the variable @code{cal-tex-rules} is
439 non-@code{nil} (the default is @code{nil}), the calendar displays ruled
440 pages in styles that have sufficient room.  Consult the documentation of
441 the individual cal-tex functions to see which calendars support which
442 features.
444   You can use the variable @code{cal-tex-preamble-extra} to insert extra
445 La@TeX{} commands in the preamble of the generated document if you need
448 @node Holidays
449 @section Holidays
450 @cindex holidays
452   The Emacs calendar knows about all major and many minor holidays,
453 and can display them.
455 @table @kbd
456 @item h
457 Display holidays for the selected date
458 (@code{calendar-cursor-holidays}).
459 @item Mouse-2 Holidays
460 Display any holidays for the date you click on.
461 @item x
462 Mark holidays in the calendar window (@code{calendar-mark-holidays}).
463 @item u
464 Unmark calendar window (@code{calendar-unmark}).
465 @item a
466 List all holidays for the displayed three months in another window
467 (@code{calendar-list-holidays}).
468 @item M-x holidays
469 List all holidays for three months around today's date in another
470 window.
471 @item M-x list-holidays
472 List holidays in another window for a specified range of years.
473 @end table
475 @kindex h @r{(Calendar mode)}
476 @findex calendar-cursor-holidays
477 @vindex calendar-view-holidays-initially-flag
478   To see if any holidays fall on a given date, position point on that
479 date in the calendar window and use the @kbd{h} command.  Alternatively,
480 click on that date with @kbd{Mouse-2} and then choose @kbd{Holidays}
481 from the menu that appears.  Either way, this displays the holidays for
482 that date, in the echo area if they fit there, otherwise in a separate
483 window.
485 @kindex x @r{(Calendar mode)}
486 @findex calendar-mark-holidays
487 @kindex u @r{(Calendar mode)}
488 @findex calendar-unmark
489 @vindex calendar-mark-holidays-flag
490   To view the distribution of holidays for all the dates shown in the
491 calendar, use the @kbd{x} command.  This displays the dates that are
492 holidays in a different face (or places a @samp{*} after these dates, if
493 a color display is not available, or if @code{font-lock-mode} is off).
494 @iftex
495 @inforef{Calendar Customizing, calendar-holiday-marker, emacs-xtra}.
496 @end iftex
497 @ifnottex
498 @xref{Calendar Customizing, calendar-holiday-marker}.
499 @end ifnottex
500   The command applies both to the currently visible months and to
501 other months that subsequently become visible by scrolling.  To turn
502 marking off and erase the current marks, type @kbd{u}, which also
503 erases any diary marks (@pxref{Diary}).  If the variable
504 @code{calendar-mark-holidays-flag} is non-@code{nil}, creating or
505 updating the calendar marks holidays automatically.
507 @kindex a @r{(Calendar mode)}
508 @findex calendar-list-holidays
509   To get even more detailed information, use the @kbd{a} command, which
510 displays a separate buffer containing a list of all holidays in the
511 current three-month range.  You can use @key{SPC} and @key{DEL} in the
512 calendar window to scroll that list up and down, respectively.
514 @findex holidays
515   The command @kbd{M-x holidays} displays the list of holidays for the
516 current month and the preceding and succeeding months; this works even
517 if you don't have a calendar window.  If the variable
518 @code{calendar-view-holidays-initially-flag} is non-@code{nil}, creating
519 the calendar displays holidays in this way.  If you want the list of
520 holidays centered around a different month, use @kbd{C-u M-x
521 holidays}, which prompts for the month and year.
523   The holidays known to Emacs include United States holidays and the
524 major Christian, Jewish, and Islamic holidays; also the solstices and
525 equinoxes.
527 @findex list-holidays
528    The command @kbd{M-x holiday-list} displays the list of holidays for
529 a range of years.  This function asks you for the starting and stopping
530 years, and allows you to choose all the holidays or one of several
531 categories of holidays.  You can use this command even if you don't have
532 a calendar window.
534   The dates used by Emacs for holidays are based on @emph{current
535 practice}, not historical fact.  For example Veteran's Day began in
536 1919, but is shown in earlier years.
538 @node Sunrise/Sunset
539 @section Times of Sunrise and Sunset
540 @cindex sunrise and sunset
542   Special calendar commands can tell you, to within a minute or two, the
543 times of sunrise and sunset for any date.
545 @table @kbd
546 @item S
547 Display times of sunrise and sunset for the selected date
548 (@code{calendar-sunrise-sunset}).
549 @item Mouse-2 Sunrise/sunset
550 Display times of sunrise and sunset for the date you click on.
551 @item M-x sunrise-sunset
552 Display times of sunrise and sunset for today's date.
553 @item C-u M-x sunrise-sunset
554 Display times of sunrise and sunset for a specified date.
555 @end table
557 @kindex S @r{(Calendar mode)}
558 @findex calendar-sunrise-sunset
559 @findex sunrise-sunset
560   Within the calendar, to display the @emph{local times} of sunrise and
561 sunset in the echo area, move point to the date you want, and type
562 @kbd{S}.  Alternatively, click @kbd{Mouse-2} on the date, then choose
563 @samp{Sunrise/sunset} from the menu that appears.  The command @kbd{M-x
564 sunrise-sunset} is available outside the calendar to display this
565 information for today's date or a specified date.  To specify a date
566 other than today, use @kbd{C-u M-x sunrise-sunset}, which prompts for
567 the year, month, and day.
569   You can display the times of sunrise and sunset for any location and
570 any date with @kbd{C-u C-u M-x sunrise-sunset}.  This asks you for a
571 longitude, latitude, number of minutes difference from Coordinated
572 Universal Time, and date, and then tells you the times of sunrise and
573 sunset for that location on that date.
575   Because the times of sunrise and sunset depend on the location on
576 earth, you need to tell Emacs your latitude, longitude, and location
577 name before using these commands.  Here is an example of what to set:
579 @vindex calendar-location-name
580 @vindex calendar-longitude
581 @vindex calendar-latitude
582 @example
583 (setq calendar-latitude 40.1)
584 (setq calendar-longitude -88.2)
585 (setq calendar-location-name "Urbana, IL")
586 @end example
588 @noindent
589 Use one decimal place in the values of @code{calendar-latitude} and
590 @code{calendar-longitude}.
592   Your time zone also affects the local time of sunrise and sunset.
593 Emacs usually gets time zone information from the operating system, but
594 if these values are not what you want (or if the operating system does
595 not supply them), you must set them yourself.  Here is an example:
597 @vindex calendar-time-zone
598 @vindex calendar-standard-time-zone-name
599 @vindex calendar-daylight-time-zone-name
600 @example
601 (setq calendar-time-zone -360)
602 (setq calendar-standard-time-zone-name "CST")
603 (setq calendar-daylight-time-zone-name "CDT")
604 @end example
606 @noindent
607 The value of @code{calendar-time-zone} is the number of minutes
608 difference between your local standard time and Coordinated Universal
609 Time (Greenwich time).  The values of
610 @code{calendar-standard-time-zone-name} and
611 @code{calendar-daylight-time-zone-name} are the abbreviations used in
612 your time zone.  Emacs displays the times of sunrise and sunset
613 @emph{corrected for daylight saving time}.  @xref{Daylight Saving},
614 for how daylight saving time is determined.
616   As a user, you might find it convenient to set the calendar location
617 variables for your usual physical location in your @file{.emacs} file.
618 And when you install Emacs on a machine, you can create a
619 @file{default.el} file which sets them properly for the typical location
620 of most users of that machine.  @xref{Init File}.
622 @node Lunar Phases
623 @section Phases of the Moon
624 @cindex phases of the moon
625 @cindex moon, phases of
627   These calendar commands display the dates and times of the phases of
628 the moon (new moon, first quarter, full moon, last quarter).  This
629 feature is useful for debugging problems that ``depend on the phase of
630 the moon.''
632 @table @kbd
633 @item M
634 Display the dates and times for all the quarters of the moon for the
635 three-month period shown (@code{calendar-phases-of-moon}).
636 @item M-x phases-of-moon
637 Display dates and times of the quarters of the moon for three months around
638 today's date.
639 @end table
641 @kindex M @r{(Calendar mode)}
642 @findex calendar-phases-of-moon
643   Within the calendar, use the @kbd{M} command to display a separate
644 buffer of the phases of the moon for the current three-month range.  The
645 dates and times listed are accurate to within a few minutes.
647 @findex phases-of-moon
648   Outside the calendar, use the command @kbd{M-x phases-of-moon} to
649 display the list of the phases of the moon for the current month and the
650 preceding and succeeding months.  For information about a different
651 month, use @kbd{C-u M-x phases-of-moon}, which prompts for the month and
652 year.
654   The dates and times given for the phases of the moon are given in
655 local time (corrected for daylight saving, when appropriate); but if
656 the variable @code{calendar-time-zone} is void, Coordinated Universal
657 Time (the Greenwich time zone) is used.  @xref{Daylight Saving}.
659 @node Other Calendars
660 @section Conversion To and From Other Calendars
662 @cindex Gregorian calendar
663   The Emacs calendar displayed is @emph{always} the Gregorian calendar,
664 sometimes called the ``new style'' calendar, which is used in most of
665 the world today.  However, this calendar did not exist before the
666 sixteenth century and was not widely used before the eighteenth century;
667 it did not fully displace the Julian calendar and gain universal
668 acceptance until the early twentieth century.  The Emacs calendar can
669 display any month since January, year 1 of the current era, but the
670 calendar displayed is the Gregorian, even for a date at which the
671 Gregorian calendar did not exist.
673   While Emacs cannot display other calendars, it can convert dates to
674 and from several other calendars.
676 @menu
677 * Calendar Systems::       The calendars Emacs understands
678                              (aside from Gregorian).
679 * To Other Calendar::      Converting the selected date to various calendars.
680 * From Other Calendar::    Moving to a date specified in another calendar.
681 * Mayan Calendar::         Moving to a date specified in a Mayan calendar.
682 @end menu
684 @node Calendar Systems
685 @subsection Supported Calendar Systems
687 @cindex ISO commercial calendar
688   The ISO commercial calendar is used largely in Europe.
690 @cindex Julian calendar
691   The Julian calendar, named after Julius Caesar, was the one used in Europe
692 throughout medieval times, and in many countries up until the nineteenth
693 century.
695 @cindex Julian day numbers
696 @cindex astronomical day numbers
697   Astronomers use a simple counting of days elapsed since noon, Monday,
698 January 1, 4713 B.C. on the Julian calendar.  The number of days elapsed
699 is called the @dfn{Julian day number} or the @dfn{Astronomical day number}.
701 @cindex Hebrew calendar
702   The Hebrew calendar is used by tradition in the Jewish religion.  The
703 Emacs calendar program uses the Hebrew calendar to determine the dates
704 of Jewish holidays.  Hebrew calendar dates begin and end at sunset.
706 @cindex Islamic calendar
707   The Islamic calendar is used in many predominantly Islamic countries.
708 Emacs uses it to determine the dates of Islamic holidays.  There is no
709 universal agreement in the Islamic world about the calendar; Emacs uses
710 a widely accepted version, but the precise dates of Islamic holidays
711 often depend on proclamation by religious authorities, not on
712 calculations.  As a consequence, the actual dates of observance can vary
713 slightly from the dates computed by Emacs.  Islamic calendar dates begin
714 and end at sunset.
716 @cindex French Revolutionary calendar
717   The French Revolutionary calendar was created by the Jacobins after the 1789
718 revolution, to represent a more secular and nature-based view of the annual
719 cycle, and to install a 10-day week in a rationalization measure similar to
720 the metric system.  The French government officially abandoned this
721 calendar at the end of 1805.
723 @cindex Mayan calendar
724   The Maya of Central America used three separate, overlapping calendar
725 systems, the @emph{long count}, the @emph{tzolkin}, and the @emph{haab}.
726 Emacs knows about all three of these calendars.  Experts dispute the
727 exact correlation between the Mayan calendar and our calendar; Emacs uses the
728 Goodman-Martinez-Thompson correlation in its calculations.
730 @cindex Coptic calendar
731 @cindex Ethiopic calendar
732   The Copts use a calendar based on the ancient Egyptian solar calendar.
733 Their calendar consists of twelve 30-day months followed by an extra
734 five-day period.  Once every fourth year they add a leap day to this
735 extra period to make it six days.  The Ethiopic calendar is identical in
736 structure, but has different year numbers and month names.
738 @cindex Persian calendar
739   The Persians use a solar calendar based on a design of Omar Khayyam.
740 Their calendar consists of twelve months of which the first six have 31
741 days, the next five have 30 days, and the last has 29 in ordinary years
742 and 30 in leap years.  Leap years occur in a complicated pattern every
743 four or five years.
744 The calendar implemented here is the arithmetical Persian calendar
745 championed by Birashk, based on a 2,820-year cycle.  It differs from
746 the astronomical Persian calendar, which is based on astronomical
747 events.  As of this writing the first future discrepancy is projected
748 to occur on March 20, 2025.  It is currently not clear what the
749 official calendar of Iran will be that far into the future.
751 @cindex Chinese calendar
752   The Chinese calendar is a complicated system of lunar months arranged
753 into solar years.  The years go in cycles of sixty, each year containing
754 either twelve months in an ordinary year or thirteen months in a leap
755 year; each month has either 29 or 30 days.  Years, ordinary months, and
756 days are named by combining one of ten ``celestial stems'' with one of
757 twelve ``terrestrial branches'' for a total of sixty names that are
758 repeated in a cycle of sixty.
760 @cindex Baha'i calendar
761   The Baha'i calendar system is based on a solar cycle of 19 months with
762 19 days each.  The four remaining ``intercalary'' days are placed
763 between the 18th and 19th months.
765 @node To Other Calendar
766 @subsection Converting To Other Calendars
768   The following commands describe the selected date (the date at point)
769 in various other calendar systems:
771 @table @kbd
772 @item Mouse-2  Other calendars
773 Display the date that you click on, expressed in various other calendars.
774 @kindex p @r{(Calendar mode)}
775 @findex calendar-iso-print-date
776 @item p c
777 Display ISO commercial calendar equivalent for selected day
778 (@code{calendar-iso-print-date}).
779 @findex calendar-julian-print-date
780 @item p j
781 Display Julian date for selected day (@code{calendar-julian-print-date}).
782 @findex calendar-astro-print-day-number
783 @item p a
784 Display astronomical (Julian) day number for selected day
785 (@code{calendar-astro-print-day-number}).
786 @findex calendar-hebrew-print-date
787 @item p h
788 Display Hebrew date for selected day (@code{calendar-hebrew-print-date}).
789 @findex calendar-islamic-print-date
790 @item p i
791 Display Islamic date for selected day (@code{calendar-islamic-print-date}).
792 @findex calendar-french-print-date
793 @item p f
794 Display French Revolutionary date for selected day
795 (@code{calendar-french-print-date}).
796 @findex calendar-bahai-print-date
797 @item p b
798 Display Baha'i date for selected day
799 (@code{calendar-bahai-print-date}).
800 @findex calendar-chinese-print-date
801 @item p C
802 Display Chinese date for selected day
803 (@code{calendar-chinese-print-date}).
804 @findex calendar-coptic-print-date
805 @item p k
806 Display Coptic date for selected day
807 (@code{calendar-coptic-print-date}).
808 @findex calendar-ethiopic-print-date
809 @item p e
810 Display Ethiopic date for selected day
811 (@code{calendar-ethiopic-print-date}).
812 @findex calendar-persian-print-date
813 @item p p
814 Display Persian date for selected day
815 (@code{calendar-persian-print-date}).
816 @findex calendar-mayan-print-date
817 @item p m
818 Display Mayan date for selected day (@code{calendar-mayan-print-date}).
819 @end table
821   If you are using X, the easiest way to translate a date into other
822 calendars is to click on it with @kbd{Mouse-2}, then choose @kbd{Other
823 calendars} from the menu that appears.  This displays the equivalent
824 forms of the date in all the calendars Emacs understands, in the form of
825 a menu.  (Choosing an alternative from this menu doesn't actually do
826 anything---the menu is used only for display.)
828   Otherwise, move point to the date you want to convert, then type the
829 appropriate command starting with @kbd{p} from the table above.  The
830 prefix @kbd{p} is a mnemonic for ``print,'' since Emacs ``prints'' the
831 equivalent date in the echo area.
833 @node From Other Calendar
834 @subsection Converting From Other Calendars
836   You can use the other supported calendars to specify a date to move
837 to.  This section describes the commands for doing this using calendars
838 other than Mayan; for the Mayan calendar, see the following section.
840 @kindex g @var{char} @r{(Calendar mode)}
841 @findex calendar-iso-goto-date
842 @findex calendar-iso-goto-week
843 @findex calendar-julian-goto-date
844 @findex calendar-astro-goto-day-number
845 @findex calendar-hebrew-goto-date
846 @findex calendar-islamic-goto-date
847 @findex calendar-french-goto-date
848 @findex calendar-chinese-goto-date
849 @findex calendar-persian-goto-date
850 @findex calendar-coptic-goto-date
851 @findex calendar-ethiopic-goto-date
852 @table @kbd
853 @item g c
854 Move to a date specified in the ISO commercial calendar
855 (@code{calendar-iso-goto-date}).
856 @item g w
857 Move to a week specified in the ISO commercial calendar
858 (@code{calendar-iso-goto-week}).
859 @item g j
860 Move to a date specified in the Julian calendar
861 (@code{calendar-julian-goto-date}).
862 @item g a
863 Move to a date specified with an astronomical (Julian) day number
864 (@code{calendar-astro-goto-day-number}).
865 @item g h
866 Move to a date specified in the Hebrew calendar
867 (@code{calendar-hebrew-goto-date}).
868 @item g i
869 Move to a date specified in the Islamic calendar
870 (@code{calendar-islamic-goto-date}).
871 @item g f
872 Move to a date specified in the French Revolutionary calendar
873 (@code{calendar-french-goto-date}).
874 @item g C
875 Move to a date specified in the Chinese calendar
876 (@code{calendar-chinese-goto-date}).
877 @item g p
878 Move to a date specified in the Persian calendar
879 (@code{calendar-persian-goto-date}).
880 @item g k
881 Move to a date specified in the Coptic calendar
882 (@code{calendar-coptic-goto-date}).
883 @item g e
884 Move to a date specified in the Ethiopic calendar
885 (@code{calendar-ethiopic-goto-date}).
886 @end table
888   These commands ask you for a date on the other calendar, move point to
889 the Gregorian calendar date equivalent to that date, and display the
890 other calendar's date in the echo area.  Emacs uses strict completion
891 (@pxref{Completion}) whenever it asks you to type a month name, so you
892 don't have to worry about the spelling of Hebrew, Islamic, or French names.
894 @findex calendar-hebrew-list-yahrzeits
895 @cindex yahrzeits
896   One common question concerning the Hebrew calendar is the computation
897 of the anniversary of a date of death, called a ``yahrzeit.''  The Emacs
898 calendar includes a facility for such calculations.  If you are in the
899 calendar, the command @kbd{M-x calendar-hebrew-list-yahrzeits} asks you for
900 a range of years and then displays a list of the yahrzeit dates for those
901 years for the date given by point.  If you are not in the calendar,
902 this command first asks you for the date of death and the range of
903 years, and then displays the list of yahrzeit dates.
905 @node Mayan Calendar
906 @subsection Converting from the Mayan Calendar
908   Here are the commands to select dates based on the Mayan calendar:
910 @table @kbd
911 @item g m l
912 Move to a date specified by the long count calendar
913 (@code{calendar-mayan-goto-long-count-date}).
914 @item g m n t
915 Move to the next occurrence of a place in the
916 tzolkin calendar (@code{calendar-mayan-next-tzolkin-date}).
917 @item g m p t
918 Move to the previous occurrence of a place in the
919 tzolkin calendar (@code{calendar-mayan-previous-tzolkin-date}).
920 @item g m n h
921 Move to the next occurrence of a place in the
922 haab calendar (@code{calendar-mayan-next-haab-date}).
923 @item g m p h
924 Move to the previous occurrence of a place in the
925 haab calendar (@code{calendar-mayan-previous-haab-date}).
926 @item g m n c
927 Move to the next occurrence of a place in the
928 calendar round (@code{calendar-mayan-next-calendar-round-date}).
929 @item g m p c
930 Move to the previous occurrence of a place in the
931 calendar round (@code{calendar-mayan-previous-calendar-round-date}).
932 @end table
934 @cindex Mayan long count
935   To understand these commands, you need to understand the Mayan calendars.
936 The @dfn{long count} is a counting of days with these units:
938 @display
939 1 kin = 1 day@ @ @ 1 uinal = 20 kin@ @ @ 1 tun = 18 uinal
940 1 katun = 20 tun@ @ @ 1 baktun = 20 katun
941 @end display
943 @kindex g m @r{(Calendar mode)}
944 @findex calendar-mayan-goto-long-count-date
945 @noindent
946 Thus, the long count date 12.16.11.16.6 means 12 baktun, 16 katun, 11
947 tun, 16 uinal, and 6 kin.  The Emacs calendar can handle Mayan long
948 count dates as early as 7.17.18.13.3, but no earlier.  When you use the
949 @kbd{g m l} command, type the Mayan long count date with the baktun,
950 katun, tun, uinal, and kin separated by periods.
952 @findex calendar-mayan-previous-tzolkin-date
953 @findex calendar-mayan-next-tzolkin-date
954 @cindex Mayan tzolkin calendar
955   The Mayan tzolkin calendar is a cycle of 260 days formed by a pair of
956 independent cycles of 13 and 20 days.  Since this cycle repeats
957 endlessly, Emacs provides commands to move backward and forward to the
958 previous or next point in the cycle.  Type @kbd{g m p t} to go to the
959 previous tzolkin date; Emacs asks you for a tzolkin date and moves point
960 to the previous occurrence of that date.  Similarly, type @kbd{g m n t}
961 to go to the next occurrence of a tzolkin date.
963 @findex calendar-mayan-previous-haab-date
964 @findex calendar-mayan-next-haab-date
965 @cindex Mayan haab calendar
966   The Mayan haab calendar is a cycle of 365 days arranged as 18 months
967 of 20 days each, followed a 5-day monthless period.  Like the tzolkin
968 cycle, this cycle repeats endlessly, and there are commands to move
969 backward and forward to the previous or next point in the cycle.  Type
970 @kbd{g m p h} to go to the previous haab date; Emacs asks you for a haab
971 date and moves point to the previous occurrence of that date.
972 Similarly, type @kbd{g m n h} to go to the next occurrence of a haab
973 date.
975 @c This is omitted because it is too long for smallbook format.
976 @c @findex calendar-mayan-previous-calendar-round-date
977 @findex calendar-mayan-next-calendar-round-date
978 @cindex Mayan calendar round
979   The Maya also used the combination of the tzolkin date and the haab
980 date.  This combination is a cycle of about 52 years called a
981 @emph{calendar round}.  If you type @kbd{g m p c}, Emacs asks you for
982 both a haab and a tzolkin date and then moves point to the previous
983 occurrence of that combination.  Use @kbd{g m n c} to move point to the
984 next occurrence of a combination.  These commands signal an error if the
985 haab/tzolkin date combination you have typed is impossible.
987   Emacs uses strict completion (@pxref{Strict Completion}) whenever it
988 asks you to type a Mayan name, so you don't have to worry about
989 spelling.
991 @node Diary
992 @section The Diary
993 @cindex diary
995   The Emacs diary keeps track of appointments or other events on a daily
996 basis, in conjunction with the calendar.  To use the diary feature, you
997 must first create a @dfn{diary file} containing a list of events and
998 their dates.  Then Emacs can automatically pick out and display the
999 events for today, for the immediate future, or for any specified
1000 date.
1002   The name of the diary file is specified by the variable
1003 @code{diary-file}; @file{~/diary} is the default.  Here's an example
1004 showing what that file looks like:
1006 @example
1007 12/22/1988  Twentieth wedding anniversary!!
1008 &1/1.       Happy New Year!
1009 10/22       Ruth's birthday.
1010 * 21, *:    Payday
1011 Tuesday--weekly meeting with grad students at 10am
1012          Supowit, Shen, Bitner, and Kapoor to attend.
1013 1/13/89     Friday the thirteenth!!
1014 &thu 4pm    squash game with Lloyd.
1015 mar 16      Dad's birthday
1016 April 15, 1989 Income tax due.
1017 &* 15       time cards due.
1018 @end example
1020 @noindent
1021 This format is essentially the same as the one used by the system's
1022 @command{calendar} utility.  This example uses extra spaces to align
1023 the event descriptions of most of the entries.  Such formatting is
1024 purely a matter of taste.
1026   Although you probably will start by creating a diary manually, Emacs
1027 provides a number of commands to let you view, add, and change diary
1028 entries.
1030 @menu
1031 * Displaying the Diary::   Viewing diary entries and associated calendar dates.
1032 * Format of Diary File::   Entering events in your diary.
1033 * Date Formats::           Various ways you can specify dates.
1034 * Adding to Diary::        Commands to create diary entries.
1035 * Special Diary Entries::  Anniversaries, blocks of dates, cyclic entries, etc.
1036 @end menu
1038 @node Displaying the Diary
1039 @subsection Displaying the Diary
1041   Once you have created a diary file, you can use the calendar to view
1042 it.  You can also view today's events outside of Calendar mode.
1044 @table @kbd
1045 @item d
1046 Display all diary entries for the selected date
1047 (@code{diary-view-entries}).
1048 @item Mouse-2 Diary
1049 Display all diary entries for the date you click on.
1050 @item s
1051 Display the entire diary file (@code{diary-show-all-entries}).
1052 @item m
1053 Mark all visible dates that have diary entries
1054 (@code{diary-mark-entries}).
1055 @item u
1056 Unmark the calendar window (@code{calendar-unmark}).
1057 @item M-x diary-print-entries
1058 Print hard copy of the diary display as it appears.
1059 @item M-x diary
1060 Display all diary entries for today's date.
1061 @item M-x diary-mail-entries
1062 Mail yourself email reminders about upcoming diary entries.
1063 @end table
1065 @kindex d @r{(Calendar mode)}
1066 @findex diary-view-entries
1067 @vindex calendar-view-diary-initially-flag
1068   Displaying the diary entries with @kbd{d} shows in a separate window
1069 the diary entries for the selected date in the calendar.  The mode line
1070 of the new window shows the date of the diary entries and any holidays
1071 that fall on that date.  If you specify a numeric argument with @kbd{d},
1072 it shows all the diary entries for that many successive days.  Thus,
1073 @kbd{2 d} displays all the entries for the selected date and for the
1074 following day.
1076   Another way to display the diary entries for a date is to click
1077 @kbd{Mouse-2} on the date, and then choose @kbd{Diary entries} from
1078 the menu that appears.  If the variable
1079 @code{calendar-view-diary-initially-flag} is non-@code{nil}, creating the
1080 calendar lists the diary entries for the current date (provided the
1081 current date is visible).
1083 @kindex m @r{(Calendar mode)}
1084 @findex diary-mark-entries
1085 @vindex calendar-mark-diary-entries-flag
1086   To get a broader view of which days are mentioned in the diary, use
1087 the @kbd{m} command.  This displays the dates that have diary entries in
1088 a different face (or places a @samp{+} after these dates, if display
1089 with multiple faces is not available).
1090 @iftex
1091 @inforef{Calendar Customizing, diary-entry-marker, emacs-xtra}.
1092 @end iftex
1093 @ifnottex
1094 @xref{Calendar Customizing, diary-entry-marker}.
1095 @end ifnottex
1096   The command applies both to the currently visible months and to
1097 other months that subsequently become visible by scrolling.  To turn
1098 marking off and erase the current marks, type @kbd{u}, which also
1099 turns off holiday marks (@pxref{Holidays}).  If the variable
1100 @code{calendar-mark-diary-entries-flag} is non-@code{nil}, creating or
1101 updating the calendar marks diary dates automatically.
1103 @kindex s @r{(Calendar mode)}
1104 @findex diary-show-all-entries
1105   To see the full diary file, rather than just some of the entries, use
1106 the @kbd{s} command.
1108   Display of selected diary entries uses invisible text to hide entries
1109 that don't apply.  The diary buffer as you see it is an illusion, so
1110 simply printing the buffer does not print what you see on your screen.
1111 There is a special command to print hard copy of the diary buffer
1112 @emph{as it appears}; this command is @kbd{M-x diary-print-entries}.
1113 It sends the data directly to the printer.  You can customize it
1114 like @code{lpr-region} (@pxref{Printing}).
1116 @findex diary
1117   The command @kbd{M-x diary} displays the diary entries for the current
1118 date, independently of the calendar display, and optionally for the next
1119 few days as well; the variable @code{diary-number-of-entries} specifies
1120 how many days to include.
1121 @iftex
1122 @inforef{Diary Customizing,, emacs-xtra}.
1123 @end iftex
1124 @ifnottex
1125 @xref{Diary Customizing, number-of-diary-entries}.
1126 @end ifnottex
1128   If you put @code{(diary)} in your @file{.emacs} file, this
1129 automatically displays a window with the day's diary entries, when you
1130 enter Emacs.  The mode line of the displayed window shows the date and
1131 any holidays that fall on that date.
1133 @findex diary-mail-entries
1134 @vindex diary-mail-days
1135   Many users like to receive notice of events in their diary as email.
1136 To send such mail to yourself, use the command @kbd{M-x
1137 diary-mail-entries}.  A prefix argument specifies how many days
1138 (starting with today) to check; otherwise, the variable
1139 @code{diary-mail-days} says how many days.
1141 @node Format of Diary File
1142 @subsection The Diary File
1143 @cindex diary file
1145 @vindex diary-file
1146   Your @dfn{diary file} is a file that records events associated with
1147 particular dates.  The name of the diary file is specified by the
1148 variable @code{diary-file}; @file{~/diary} is the default.  The
1149 @code{calendar} utility program supports a subset of the format allowed
1150 by the Emacs diary facilities, so you can use that utility to view the
1151 diary file, with reasonable results aside from the entries it cannot
1152 understand.
1154   Each entry in the diary file describes one event and consists of one
1155 or more lines.  An entry always begins with a date specification at the
1156 left margin.  The rest of the entry is simply text to describe the
1157 event.  If the entry has more than one line, then the lines after the
1158 first must begin with whitespace to indicate they continue a previous
1159 entry.  Lines that do not begin with valid dates and do not continue a
1160 preceding entry are ignored.
1162   You can inhibit the marking of certain diary entries in the calendar
1163 window; to do this, insert an ampersand (@samp{&}) at the beginning of
1164 the entry, before the date.  This has no effect on display of the entry
1165 in the diary window; it affects only marks on dates in the calendar
1166 window.  Nonmarking entries are especially useful for generic entries
1167 that would otherwise mark many different dates.
1169   If the first line of a diary entry consists only of the date or day
1170 name with no following blanks or punctuation, then the diary window
1171 display doesn't include that line; only the continuation lines appear.
1172 For example, this entry:
1174 @example
1175 02/11/1989
1176       Bill B. visits Princeton today
1177       2pm Cognitive Studies Committee meeting
1178       2:30-5:30 Liz at Lawrenceville
1179       4:00pm Dentist appt
1180       7:30pm Dinner at George's
1181       8:00-10:00pm concert
1182 @end example
1184 @noindent
1185 appears in the diary window without the date line at the beginning.
1186 This style of entry looks neater when you display just a single day's
1187 entries, but can cause confusion if you ask for more than one day's
1188 entries.
1190   You can edit the diary entries as they appear in the window, but it is
1191 important to remember that the buffer displayed contains the @emph{entire}
1192 diary file, with portions of it concealed from view.  This means, for
1193 instance, that the @kbd{C-f} (@code{forward-char}) command can put point
1194 at what appears to be the end of the line, but what is in reality the
1195 middle of some concealed line.
1197   @emph{Be careful when editing the diary entries!}  Inserting
1198 additional lines or adding/deleting characters in the middle of a
1199 visible line cannot cause problems, but editing at the end of a line may
1200 not do what you expect.  Deleting a line may delete other invisible
1201 entries that follow it.  Before editing the diary, it is best to display
1202 the entire file with @kbd{s} (@code{diary-show-all-entries}).
1204 @node Date Formats
1205 @subsection Date Formats
1207   Here are some sample diary entries, illustrating different ways of
1208 formatting a date.  The examples all show dates in American order
1209 (month, day, year), but Calendar mode supports European order (day,
1210 month, year) and ISO order (year, month, day) as options.
1212 @example
1213 4/20/93  Switch-over to new tabulation system
1214 apr. 25  Start tabulating annual results
1215 4/30  Results for April are due
1216 */25  Monthly cycle finishes
1217 Friday  Don't leave without backing up files
1218 @end example
1220   The first entry appears only once, on April 20, 1993.  The second and
1221 third appear every year on the specified dates, and the fourth uses a
1222 wildcard (asterisk) for the month, so it appears on the 25th of every
1223 month.  The final entry appears every week on Friday.
1225   You can use just numbers to express a date, as in
1226 @samp{@var{month}/@var{day}} or @samp{@var{month}/@var{day}/@var{year}}.
1227 This must be followed by a nondigit.  In the date itself, @var{month}
1228 and @var{day} are numbers of one or two digits.  The optional @var{year}
1229 is also a number, and may be abbreviated to the last two digits; that
1230 is, you can use @samp{11/12/1989} or @samp{11/12/89}.
1232   Dates can also have the form @samp{@var{monthname} @var{day}} or
1233 @samp{@var{monthname} @var{day}, @var{year}}, where the month's name can
1234 be spelled in full or abbreviated (with or without a period).  The
1235 preferred abbreviations can be controlled using the variables
1236 @code{calendar-abbrev-length}, @code{calendar-month-abbrev-array}, and
1237 @code{calendar-day-abbrev-array}.  The default is to use the first three
1238 letters of a name as its abbreviation.  Case is not significant.
1240   A date may be @dfn{generic}; that is, partially unspecified.  Then the
1241 entry applies to all dates that match the specification.  If the date
1242 does not contain a year, it is generic and applies to any year.
1243 Alternatively, @var{month}, @var{day}, or @var{year} can be a @samp{*};
1244 this matches any month, day, or year, respectively.  Thus, a diary entry
1245 @samp{3/*/*} matches any day in March of any year; so does @samp{march
1248 @vindex calendar-date-style
1249 @findex calendar-set-date-style
1250   If you prefer the European style of writing dates (in which the day
1251 comes before the month), or the ISO style (in which the order is year,
1252 month, day), type @kbd{M-x calendar-set-date-style} while in the
1253 calendar, or customize the variable @code{calendar-date-style}.  This
1254 affects how diary dates are interpreted, date display, and the order in
1255 which some commands expect their arguments to be given.
1257   You can use the name of a day of the week as a generic date which
1258 applies to any date falling on that day of the week.  You can abbreviate
1259 the day of the week to three letters (with or without a period) or spell
1260 it in full; case is not significant.
1262 @node Adding to Diary
1263 @subsection Commands to Add to the Diary
1265   While in the calendar, there are several commands to create diary
1266 entries:
1268 @table @kbd
1269 @item i d
1270 Add a diary entry for the selected date (@code{diary-insert-entry}).
1271 @item i w
1272 Add a diary entry for the selected day of the week (@code{diary-insert-weekly-entry}).
1273 @item i m
1274 Add a diary entry for the selected day of the month (@code{diary-insert-monthly-entry}).
1275 @item i y
1276 Add a diary entry for the selected day of the year (@code{diary-insert-yearly-entry}).
1277 @end table
1279 @kindex i d @r{(Calendar mode)}
1280 @findex diary-insert-entry
1281   You can make a diary entry for a specific date by selecting that date
1282 in the calendar window and typing the @kbd{i d} command.  This command
1283 displays the end of your diary file in another window and inserts the
1284 date; you can then type the rest of the diary entry.
1286 @kindex i w @r{(Calendar mode)}
1287 @findex diary-insert-weekly-entry
1288 @kindex i m @r{(Calendar mode)}
1289 @findex diary-insert-monthly-entry
1290 @kindex i y @r{(Calendar mode)}
1291 @findex diary-insert-yearly-entry
1292   If you want to make a diary entry that applies to a specific day of
1293 the week, select that day of the week (any occurrence will do) and type
1294 @kbd{i w}.  This inserts the day-of-week as a generic date; you can then
1295 type the rest of the diary entry.  You can make a monthly diary entry in
1296 the same fashion: select the day of the month, use the @kbd{i m}
1297 command, and type the rest of the entry.  Similarly, you can insert a
1298 yearly diary entry with the @kbd{i y} command.
1300   All of the above commands make marking diary entries by default.  To
1301 make a nonmarking diary entry, give a numeric argument to the command.
1302 For example, @kbd{C-u i w} makes a nonmarking weekly diary entry.
1304   When you modify the diary file, be sure to save the file before
1305 exiting Emacs.  Saving the diary file after using any of the above
1306 insertion commands will automatically update the diary marks in the
1307 calendar window, if appropriate.  You can use the command
1308 @code{calendar-redraw} to force an update at any time.
1310 @node Special Diary Entries
1311 @subsection Special Diary Entries
1313   In addition to entries based on calendar dates, the diary file can
1314 contain @dfn{sexp entries} for regular events such as anniversaries.
1315 These entries are based on Lisp expressions (sexps) that Emacs evaluates
1316 as it scans the diary file.  Instead of a date, a sexp entry contains
1317 @samp{%%} followed by a Lisp expression which must begin and end with
1318 parentheses.  The Lisp expression determines which dates the entry
1319 applies to.
1321   Calendar mode provides commands to insert certain commonly used
1322 sexp entries:
1324 @table @kbd
1325 @item i a
1326 Add an anniversary diary entry for the selected date
1327 (@code{diary-insert-anniversary-entry}).
1328 @item i b
1329 Add a block diary entry for the current region
1330 (@code{diary-insert-block-entry}).
1331 @item i c
1332 Add a cyclic diary entry starting at the date
1333 (@code{diary-insert-cyclic-entry}).
1334 @end table
1336 @kindex i a @r{(Calendar mode)}
1337 @findex diary-insert-anniversary-entry
1338   If you want to make a diary entry that applies to the anniversary of a
1339 specific date, move point to that date and use the @kbd{i a} command.
1340 This displays the end of your diary file in another window and inserts
1341 the anniversary description; you can then type the rest of the diary
1342 entry.  The entry looks like this:
1344 @findex diary-anniversary
1345 @example
1346 %%(diary-anniversary 10 31 1948) Arthur's birthday
1347 @end example
1349 @noindent
1350 This entry applies to October 31 in any year after 1948; @samp{10 31
1351 1948} specifies the date.  (If you are using the European or ISO
1352 calendar style, the input order of month, day and year is different.)
1353 The reason this expression requires a beginning year is that advanced
1354 diary functions can use it to calculate the number of elapsed years.
1356   A @dfn{block} diary entry applies to a specified range of consecutive
1357 dates.  Here is a block diary entry that applies to all dates from June
1358 24, 1990 through July 10, 1990:
1360 @findex diary-block
1361 @example
1362 %%(diary-block 6 24 1990 7 10 1990) Vacation
1363 @end example
1365 @noindent
1366 The @samp{6 24 1990} indicates the starting date and the @samp{7 10 1990}
1367 indicates the stopping date.  (Again, if you are using the European or ISO
1368 calendar style, the input order of month, day and year is different.)
1370 @kindex i b @r{(Calendar mode)}
1371 @findex diary-insert-block-entry
1372   To insert a block entry, place point and the mark on the two
1373 dates that begin and end the range, and type @kbd{i b}.  This command
1374 displays the end of your diary file in another window and inserts the
1375 block description; you can then type the diary entry.
1377 @kindex i c @r{(Calendar mode)}
1378 @findex diary-insert-cyclic-entry
1379    @dfn{Cyclic} diary entries repeat after a fixed interval of days.  To
1380 create one, select the starting date and use the @kbd{i c} command.  The
1381 command prompts for the length of interval, then inserts the entry,
1382 which looks like this:
1384 @findex diary-cyclic
1385 @example
1386 %%(diary-cyclic 50 3 1 1990) Renew medication
1387 @end example
1389 @noindent
1390 This entry applies to March 1, 1990 and every 50th day following;
1391 @samp{3 1 1990} specifies the starting date.  (If you are using the
1392 European or ISO calendar style, the input order of month, day and year
1393 is different.)
1395   All three of these commands make marking diary entries.  To insert a
1396 nonmarking entry, give a numeric argument to the command.  For example,
1397 @kbd{C-u i a} makes a nonmarking anniversary diary entry.
1399   Marking sexp diary entries in the calendar is @emph{extremely}
1400 time-consuming, since every date visible in the calendar window must be
1401 individually checked.  So it's a good idea to make sexp diary entries
1402 nonmarking (with @samp{&}) when possible.
1404   Another sophisticated kind of sexp entry, a @dfn{floating} diary entry,
1405 specifies a regularly occurring event by offsets specified in days,
1406 weeks, and months.  It is comparable to a crontab entry interpreted by
1407 the @code{cron} utility.  Here is a nonmarking, floating diary entry
1408 that applies to the fourth Thursday in November:
1410 @findex diary-float
1411 @example
1412 &%%(diary-float 11 4 4) American Thanksgiving
1413 @end example
1415 @noindent
1416 The 11 specifies November (the eleventh month), the 4 specifies Thursday
1417 (the fourth day of the week, where Sunday is numbered zero), and the
1418 second 4 specifies the fourth Thursday (1 would mean ``first,'' 2 would
1419 mean ``second,'' @minus{}2 would mean ``second-to-last,'' and so on).
1420 The month can be a single month or a list of months.  Thus you could change
1421 the 11 above to @samp{'(1 2 3)} and have the entry apply to the last
1422 Thursday of January, February, and March.  If the month is @code{t}, the
1423 entry applies to all months of the year.@refill
1425   Each of the standard sexp diary entries takes an optional parameter
1426 specifying the name of a face or a single-character string to use when
1427 marking the entry in the calendar.  Most generally, sexp diary entries
1428 can perform arbitrary computations to determine when they apply.
1429 @iftex
1430 @inforef{Sexp Diary Entries,, emacs-xtra}.
1431 @end iftex
1432 @ifnottex
1433 @inforef{Sexp Diary Entries}.
1434 @end ifnottex
1436 @node Appointments
1437 @section Appointments
1438 @cindex appointment notification
1440 @vindex appt-display-format
1441 @vindex appt-audible
1442 @vindex appt-display-mode-line
1443   If you have a diary entry for an appointment, and that diary entry
1444 begins with a recognizable time of day, Emacs can warn you several
1445 minutes beforehand that that appointment is pending.  Emacs alerts you
1446 to the appointment by displaying a message in your chosen format, as
1447 specified by the variable @code{appt-display-format}.  If the value of
1448 @code{appt-audible} is non-@code{nil}, the warning includes an audible
1449 reminder.  In addition, if @code{appt-display-mode-line} is
1450 non-@code{nil}, Emacs displays the number of minutes to the
1451 appointment on the mode line.
1453 @vindex appt-display-duration
1454 @vindex appt-disp-window-function
1455 @vindex appt-delete-window-function
1456   If @code{appt-display-format} has the value @code{window}, then the
1457 variable @code{appt-display-duration} controls how long the reminder
1458 window is visible for; and the variables
1459 @code{appt-disp-window-function} and @code{appt-delete-window-function}
1460 give the names of functions used to create and destroy the window,
1461 respectively.
1463 @findex appt-activate
1464   To enable appointment notification, use the command @kbd{M-x
1465 appt-activate}.  With a positive argument, it enables notification;
1466 with a negative argument, it disables notification; with no argument,
1467 it toggles.  Enabling notification also sets up an appointment list
1468 for today from the diary file, giving all diary entries found with
1469 recognizable times of day, and reminds you just before each of them.
1471   For example, suppose the diary file contains these lines:
1473 @example
1474 Monday
1475   9:30am Coffee break
1476  12:00pm Lunch
1477 @end example
1479 @vindex appt-message-warning-time
1480 @noindent
1481 Then on Mondays, you will be reminded at around 9:20am about your
1482 coffee break and at around 11:50am about lunch.  The variable
1483 @code{appt-message-warning-time} specifies how many minutes in advance
1484 to warn you; its default value is 12 (12 minutes).
1486   You can write times in am/pm style (with @samp{12:00am} standing
1487 for midnight and @samp{12:00pm} standing for noon), or 24-hour
1488 European/military style.  You need not be consistent; your diary file
1489 can have a mixture of the two styles.  Times must be at the beginning
1490 of lines if they are to be recognized.
1492 @vindex appt-display-diary
1493   Emacs updates the appointments list from the diary file
1494 automatically just after midnight.  You can force an update at any
1495 time by re-enabling appointment notification.  Both these actions also
1496 display the day's diary buffer, unless you set
1497 @code{appt-display-diary} to @code{nil}.  The appointments list is
1498 also updated whenever the diary file is saved.
1500 @findex appt-add
1501 @findex appt-delete
1502 @cindex alarm clock
1503   You can also use the appointment notification facility like an alarm
1504 clock.  The command @kbd{M-x appt-add} adds entries to the appointment
1505 list without affecting your diary file.  You delete entries from the
1506 appointment list with @kbd{M-x appt-delete}.
1508 @node Importing Diary
1509 @section Importing and Exporting Diary Entries
1511   You can transfer diary entries between Emacs diary files and a
1512 variety of other formats.
1514 @vindex diary-outlook-formats
1515   You can import diary entries from Outlook-generated appointment
1516 messages.  While viewing such a message in Rmail or Gnus, do @kbd{M-x
1517 diary-from-outlook} to import the entry.  You can make this command
1518 recognize additional appointment message formats by customizing the
1519 variable @code{diary-outlook-formats}.
1521 @cindex iCalendar support
1522   The icalendar package allows you to transfer data between your Emacs
1523 diary file and iCalendar files, which are defined in ``RFC
1524 2445---Internet Calendaring and Scheduling Core Object Specification
1525 (iCalendar)'' (as well as the earlier vCalendar format).
1527   Importing works for ``ordinary'' (i.e. non-recurring) events, but
1528 (at present) may not work correctly (if at all) for recurring events.
1529 Exporting of diary files into iCalendar files should work correctly
1530 for most diary entries.  This feature is a work in progress, so the
1531 commands may evolve in future.
1533 @findex icalendar-import-buffer
1534   The command @code{icalendar-import-buffer} extracts
1535 iCalendar data from the current buffer and adds it to your (default)
1536 diary file.  This function is also suitable for automatic extraction of
1537 iCalendar data; for example with the Rmail mail client one could use:
1539 @example
1540 (add-hook 'rmail-show-message-hook 'icalendar-import-buffer)
1541 @end example
1543 @findex icalendar-import-file
1544   The command @code{icalendar-import-file} imports an iCalendar file
1545 and adds the results to an Emacs diary file.  For example:
1547 @example
1548 (icalendar-import-file "/here/is/calendar.ics"
1549                        "/there/goes/ical-diary")
1550 @end example
1552 @noindent
1553 You can use an @code{#include} directive to add the import file contents
1554 to the main diary file, if these are different files.
1555 @iftex
1556 @inforef{Fancy Diary Display,, emacs-xtra}.
1557 @end iftex
1558 @ifnottex
1559 @xref{Fancy Diary Display}.
1560 @end ifnottex
1563 @findex icalendar-export-file, icalendar-export-region
1564   Use @code{icalendar-export-file} to interactively export an entire
1565 Emacs diary file to iCalendar format.  To export only a part of a diary
1566 file, mark the relevant area, and call @code{icalendar-export-region}.
1567 In both cases the result is appended to the target file.
1569 @node Daylight Saving
1570 @section Daylight Saving Time
1571 @cindex daylight saving time
1573   Emacs understands the difference between standard time and daylight
1574 saving time---the times given for sunrise, sunset, solstices,
1575 equinoxes, and the phases of the moon take that into account.  The rules
1576 for daylight saving time vary from place to place and have also varied
1577 historically from year to year.  To do the job properly, Emacs needs to
1578 know which rules to use.
1580 @vindex calendar-daylight-savings-starts
1581 @vindex calendar-daylight-savings-ends
1582   Some operating systems keep track of the rules that apply to the place
1583 where you are; on these systems, Emacs gets the information it needs
1584 from the system automatically.  If some or all of this information is
1585 missing, Emacs fills in the gaps with the rules currently used in
1586 Cambridge, Massachusetts.  If the resulting rules are not what you want,
1587 you can tell Emacs the rules to use by setting certain variables:
1588 @code{calendar-daylight-savings-starts} and
1589 @code{calendar-daylight-savings-ends}.
1591   These values should be Lisp expressions that refer to the variable
1592 @code{year}, and evaluate to the Gregorian date on which daylight
1593 saving time starts or (respectively) ends, in the form of a list
1594 @code{(@var{month} @var{day} @var{year})}.  The values should be
1595 @code{nil} if your area does not use daylight saving time.
1597   Emacs uses these expressions to determine the starting date of
1598 daylight saving time for the holiday list and for correcting times of
1599 day in the solar and lunar calculations.
1601   The values for Cambridge, Massachusetts are as follows:
1603 @example
1604 (calendar-nth-named-day 2 0 3 year)
1605 (calendar-nth-named-day 1 0 11 year)
1606 @end example
1608 @noindent
1609 That is, the second 0th day (Sunday) of the third month (March) in
1610 the year specified by @code{year}, and the first Sunday of the eleventh month
1611 (November) of that year.  If daylight saving time were
1612 changed to start on October 1, you would set
1613 @code{calendar-daylight-savings-starts} to this:
1615 @example
1616 (list 10 1 year)
1617 @end example
1619   If there is no daylight saving time at your location, or if you want
1620 all times in standard time, set @code{calendar-daylight-savings-starts}
1621 and @code{calendar-daylight-savings-ends} to @code{nil}.
1623 @vindex calendar-daylight-time-offset
1624   The variable @code{calendar-daylight-time-offset} specifies the
1625 difference between daylight saving time and standard time, measured in
1626 minutes.  The value for Cambridge, Massachusetts is 60.
1628 @c @vindex calendar-daylight-savings-starts-time  too long!
1629 @vindex calendar-daylight-savings-ends-time
1630   Finally, the two variables
1631 @code{calendar-daylight-savings-starts-time} and
1632 @code{calendar-daylight-savings-ends-time} specify the number of
1633 minutes after midnight local time when the transition to and from
1634 daylight saving time should occur.  For Cambridge, Massachusetts both
1635 variables' values are 120.
1637 @node Time Intervals
1638 @section Summing Time Intervals
1639 @cindex time intervals, summing
1640 @cindex summing time intervals
1641 @cindex timeclock
1643   The timeclock feature adds up time intervals, so you can (for
1644 instance) keep track of how much time you spend working on particular
1645 projects.
1647 @findex timeclock-in
1648 @findex timeclock-out
1649 @findex timeclock-change
1650 @findex timeclock-workday-remaining
1651 @findex timeclock-when-to-leave
1652   Use the @kbd{M-x timeclock-in} command when you start working on a
1653 project, and @kbd{M-x timeclock-out} command when you're done.  Each
1654 time you do this, it adds one time interval to the record of the
1655 project.  You can change to working on a different project with @kbd{M-x
1656 timeclock-change}.
1658   Once you've collected data from a number of time intervals, you can use
1659 @kbd{M-x timeclock-workday-remaining} to see how much time is left to
1660 work today (assuming a typical average of 8 hours a day), and @kbd{M-x
1661 timeclock-when-to-leave} which will calculate when you're ``done.''
1663 @vindex timeclock-modeline-display
1664 @findex timeclock-modeline-display
1665   If you want Emacs to display the amount of time ``left'' of your
1666 workday in the mode line, either customize the
1667 @code{timeclock-modeline-display} variable and set its value to
1668 @code{t}, or invoke the @kbd{M-x timeclock-modeline-display} command.
1670 @vindex timeclock-ask-before-exiting
1671   Terminating the current Emacs session might or might not mean that
1672 you have stopped working on the project and, by default, Emacs asks
1673 you.  You can, however, set the value of the variable
1674 @code{timeclock-ask-before-exiting} to @code{nil} (via @kbd{M-x
1675 customize}) to avoid the question; then, only an explicit @kbd{M-x
1676 timeclock-out} or @kbd{M-x timeclock-change} will tell Emacs that the
1677 current interval is over.
1679 @cindex @file{.timelog} file
1680 @vindex timeclock-file
1681 @findex timeclock-reread-log
1682   The timeclock functions work by accumulating the data in a file
1683 called @file{.timelog} in your home directory.  You can specify a
1684 different name for this file by customizing the variable
1685 @code{timeclock-file}.  If you edit the timeclock file manually, or if
1686 you change the value of any of timeclock's customizable variables, you
1687 should run the command @kbd{M-x timeclock-reread-log} to update the
1688 data in Emacs from the file.
1690 @ifnottex
1691 @include cal-xtra.texi
1692 @end ifnottex
1694 @ignore
1695    arch-tag: 4531ef09-9df3-449d-9c52-2b5a4a337f92
1696 @end ignore