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