1ZSHCALSYS(1)                General Commands Manual               ZSHCALSYS(1)
2
3
4

NAME

6       zshcalsys - zsh calendar system
7

DESCRIPTION

9       The shell is supplied with a series of functions to replace and enhance
10       the traditional Unix calendar programme, which warns the user of  immi‐
11       nent or future events, details of which are stored in a text file (typ‐
12       ically calendar in the user's home directory).   The  version  provided
13       here includes a mechanism for alerting the user when an event is due.
14
15       In addition a function age is provided that can be used in a glob qual‐
16       ifier; it allows files to  be  selected  based  on  their  modification
17       times.
18
19       The  format of the calendar file and the dates used there in and in the
20       age function are described first, then the functions that can be called
21       to examine and modify the calendar file.
22
23       The  functions here depend on the availability of the zsh/datetime mod‐
24       ule which is usually installed with the shell.   The  library  function
25       strptime()  must  be  available; it is present on most recent operating
26       systems.
27

FILE AND DATE FORMATS

29   Calendar File Format
30       The calendar file is by default ~/calendar.  This can be configured  by
31       the  calendar-file style, see the section STYLES below.  The basic for‐
32       mat consists of a series of separate lines, with no  indentation,  each
33       including  a  date  and time specification followed by a description of
34       the event.
35
36       Various enhancements to this format are supported, based on the  syntax
37       of Emacs calendar mode.  An indented line indicates a continuation line
38       that continues the description of the event  from  the  preceding  line
39       (note the date may not be continued in this way).  An initial ampersand
40       (&) is ignored for compatibility.
41
42       An indented line on which the first non-whitespace character  is  #  is
43       not  displayed with the calendar entry, but is still scanned for infor‐
44       mation.  This can be used to hide information useful  to  the  calendar
45       system  but not to the user, such as the unique identifier used by cal‐
46       endar_add.
47
48       The Emacs extension that a date with no description may refer to a num‐
49       ber of succeeding events at different times is not supported.
50
51       Unless the done-file style has been altered, any events which have been
52       processed are appended to the file with the same name as  the  calendar
53       file with the suffix .done, hence ~/calendar.done by default.
54
55       An example is shown below.
56
57   Date Format
58       The  format of the date and time is designed to allow flexibility with‐
59       out admitting ambiguity.  (The words `date' and `time' are both used in
60       the documentation below; except where specifically noted this implies a
61       string that may include both a date and a  time  specification.)   Note
62       that  there  is no localization support; month and day names must be in
63       English and separator characters are fixed.  Matching is case  insensi‐
64       tive,  and  only  the first three letters of the names are significant,
65       although as a special case a form  beginning  "month"  does  not  match
66       "Monday".   Furthermore,  time  zones  are  not  handled; all times are
67       assumed to be local.
68
69       It is recommended that, rather than exploring the  intricacies  of  the
70       system,  users  find a date format that is natural to them and stick to
71       it.  This will avoid unexpected effects.  Various key facts  should  be
72       noted.
73
74       ·      In  particular,  note  the  confusion between month/day/year and
75              day/month/year when the month is numeric; these  formats  should
76              be avoided if at all possible.  Many alternatives are available.
77
78       ·      The  year  must  be  given  in full to avoid confusion, and only
79              years from 1900 to 2099 inclusive are matched.
80
81       The following give some obvious examples; users finding here  a  format
82       they  like  and  not  subject  to  vagaries  of style may skip the full
83       description.  As dates and times are matched  separately  (even  though
84       the  time  may  be  embedded in the date), any date format may be mixed
85       with any format for the time of day provide the  separators  are  clear
86       (whitespace, colons, commas).
87
88              2007/04/03 13:13
89              2007/04/03:13:13
90              2007/04/03 1:13 pm
91              3rd April 2007, 13:13
92              April 3rd 2007 1:13 p.m.
93              Apr 3, 2007 13:13
94              Tue Apr 03 13:13:00 2007
95              13:13 2007/apr/3
96
97       More detailed rules follow.
98
99       Times  are  parsed and extracted before dates.  They must use colons to
100       separate hours and minutes, though a dot is allowed before  seconds  if
101       they are present.  This limits time formats to the following:
102
103       ·      HH:MM[:SS[.FFFFF]] [am|pm|a.m.|p.m.]
104
105       ·      HH:MM.SS[.FFFFF] [am|pm|a.m.|p.m.]
106
107       Here,  square brackets indicate optional elements, possibly with alter‐
108       natives.  Fractions of a second are recognised but ignored.  For  abso‐
109       lute  times (the normal format require by the calendar file and the age
110       function) a date is mandatory but a  time  of  day  is  not;  the  time
111       returned  is  at  the  start of the date.  One variation is allowed: if
112       a.m. or p.m. or one of their variants is present,  an  hour  without  a
113       minute is allowed, e.g. 3 p.m..
114
115       Time  zones  are not handled, though if one is matched following a time
116       specification it will be removed to allow  a  surrounding  date  to  be
117       parsed.   This  only  happens  if the format of the timezone is not too
118       unusual.  The following are examples of forms that are understood:
119
120              +0100
121              GMT
122              GMT-7
123              CET+1CDT
124
125       Any part of the timezone that is not numeric must  have  exactly  three
126       capital letters in the name.
127
128       Dates  suffer from the ambiguity between DD/MM/YYYY and MM/DD/YYYY.  It
129       is recommended this form is avoided with purely numeric dates, but  use
130       of ordinals, eg. 3rd/04/2007, will resolve the ambiguity as the ordinal
131       is always parsed as the day of the month.  Years must  be  four  digits
132       (and  the  first  two  must  be  19 or 20); 03/04/08 is not recognised.
133       Other numbers may have leading zeroes, but they are not required.   The
134       following are handled:
135
136       ·      YYYY/MM/DD
137
138       ·      YYYY-MM-DD
139
140       ·      YYYY/MNM/DD
141
142       ·      YYYY-MNM-DD
143
144       ·      DD[th|st|rd] MNM[,] [ YYYY ]
145
146       ·      MNM DD[th|st|rd][,] [ YYYY ]
147
148       ·      DD[th|st|rd]/MM[,] YYYY
149
150       ·      DD[th|st|rd]/MM/YYYY
151
152       ·      MM/DD[th|st|rd][,] YYYY
153
154       ·      MM/DD[th|st|rd]/YYYY
155
156       Here,  MNM is at least the first three letters of a month name, matched
157       case-insensitively.  The remainder of the month name may appear but its
158       contents  are  irrelevant,  so  janissary,  febrile,  martial, apricot,
159       maybe, junta, etc. are happily handled.
160
161       Where the year is shown as  optional,  the  current  year  is  assumed.
162       There  are  only  two  such cases, the form Jun 20 or 14 September (the
163       only two commonly occurring forms, apart from a "the" in some forms  of
164       English,  which  isn't currently supported).  Such dates will of course
165       become ambiguous in the future, so should ideally be avoided.
166
167       Times may follow dates with a colon, e.g. 1965/07/12:09:45; this is  in
168       order  to  provide a format with no whitespace.  A comma and whitespace
169       are allowed, e.g. 1965/07/12, 09:45.  Currently the order of these sep‐
170       arators  is  not  checked,  so  illogical formats such as 1965/07/12, :
171       ,09:45 will also be matched.  For simplicity such  variations  are  not
172       shown in the list above.  Otherwise, a time is only recognised as being
173       associated with a date if there is only whitespace in  between,  or  if
174       the time was embedded in the date.
175
176       Days  of the week are not normally scanned, but will be ignored if they
177       occur at the start of the date  pattern  only.   However,  in  contexts
178       where it is useful to specify dates relative to today, days of the week
179       with no other date specification may be given.  The day is  assumed  to
180       be  either  today or within the past week.  Likewise, the words yester‐
181       day, today and tomorrow are handled.  All matches are case-insensitive.
182       Hence  if today is Monday, then Sunday is equivalent to yesterday, Mon‐
183       day is equivalent to today, but Tuesday gives  a  date  six  days  ago.
184       This  is  not generally useful within the calendar file.  Dates in this
185       format may be combined with a time specification; for example Tomorrow,
186       8 p.m..
187
188       For example, the standard date format:
189
190              Fri Aug 18 17:00:48 BST 2006
191
192       is  handled  by  matching  HH:MM:SS  and  removing it together with the
193       matched (but unused) time zone.  This leaves the following:
194
195              Fri Aug 18 2006
196
197       Fri is ignored and the rest is matched according to the standard rules.
198
199   Relative Time Format
200       In certain places relative times are handled.   Here,  a  date  is  not
201       allowed;  instead  a  combination  of  various  supported  periods  are
202       allowed, together with an optional time.  The periods must be in  order
203       from most to least significant.
204
205       In some cases, a more accurate calculation is possible when there is an
206       anchor date:  offsets of months or years pick the correct  day,  rather
207       than  being  rounded,  and it is possible to pick a particular day in a
208       month as `(1st Friday)', etc., as described in more detail below.
209
210       Anchors are available in the following cases.  If one or two times  are
211       passed  to the function calendar, the start time acts an anchor for the
212       end time when the end time is relative  (even  if  the  start  time  is
213       implicit).   When  examining  calendar files, the scheduled event being
214       examined anchors the warning time when it is given explicitly by  means
215       of the WARN keyword; likewise, the scheduled event anchors a repetition
216       period when given by the RPT keyword, so that  specifications  such  as
217       RPT 2 months, 3rd Thursday are handled properly.  Finally, the -R argu‐
218       ment to calendar_scandate directly provides an anchor for relative cal‐
219       culations.
220
221       The periods handled, with possible abbreviations are:
222
223       Years  years,  yrs,  ys,  year,  yr,  y, yearly.  A year is 365.25 days
224              unless there is an anchor.
225
226       Months months, mons, mnths, mths, month, mon, mnth, mth, monthly.  Note
227              that  m, ms, mn, mns are ambiguous and are not handled.  A month
228              is a period of 30 days rather than a calendar month unless there
229              is an anchor.
230
231       Weeks  weeks, wks, ws, week, wk, w, weekly
232
233       Days   days, dys, ds, day, dy, d, daily
234
235       Hours  hours, hrs, hs, hour, hr, h, hourly
236
237       Minutes
238              minutes, mins, minute, min, but not m, ms, mn or mns
239
240       Seconds
241              seconds, secs, ss, second, sec, s
242
243       Spaces  between  the  numbers  are  optional,  but are required between
244       items, although a comma may be used (with or without spaces).
245
246       The forms yearly to hourly allow  the  number  to  be  omitted;  it  is
247       assumed to be 1.  For example, 1 d and daily are equivalent.  Note that
248       using those forms with plurals is confusing; 2 yearly is the same as  2
249       years, not twice yearly, so it is recommended they only be used without
250       numbers.
251
252       When an anchor time is present, there is an extension to handle regular
253       events  in the form of the nth someday of the month.  Such a specifica‐
254       tion must occur immediately after any year and month specification, but
255       before  any  time  of day, and must be in the form n(th|st|rd) day, for
256       example 1st Tuesday or 3rd  Monday.   As  in  other  places,  days  are
257       matched  case  insensitively,  must  be  in English, and only the first
258       three letters are significant except that a form beginning `month' does
259       not match `Monday'.  No attempt is made to sanitize the resulting date;
260       attempts to squeeze too many occurrences into a month will push the day
261       into  the next month (but in the obvious fashion, retaining the correct
262       day of the week).
263
264       Here are some examples:
265
266              30 years 3 months 4 days 3:42:41
267              14 days 5 hours
268              Monthly, 3rd Thursday
269              4d,10hr
270
271   Example
272       Here is an example calendar file.  It uses a consistent date format, as
273       recommended above.
274
275              Feb 1, 2006 14:30 Pointless bureaucratic meeting
276              Mar 27, 2006 11:00 Mutual recrimination and finger pointing
277                Bring water pistol and waterproofs
278              Mar 31, 2006 14:00 Very serious managerial pontification
279                # UID 12C7878A9A50
280              Apr 10, 2006 13:30 Even more pointless blame assignment exercise WARN 30 mins
281              May 18, 2006 16:00 Regular moaning session RPT monthly, 3rd Thursday
282
283       The  second  entry has a continuation line.  The third entry has a con‐
284       tinuation line that will not be shown when the entry is displayed,  but
285       the  unique  identifier  will be used by the calendar_add function when
286       updating the event.  The fourth entry will produce a warning 30 minutes
287       before  the  event (to allow you to equip yourself appropriately).  The
288       fifth entry repeats after a month on the 3rd Thursday,  i.e.  June  15,
289       2006, at the same time.
290

USER FUNCTIONS

292       This  section  describes  functions  that  are  designed  to  be called
293       directly by the user.  The first part describes those functions associ‐
294       ated  with  the  user's  calendar; the second part describes the use in
295       glob qualifiers.
296
297   Calendar system functions
298       calendar [ -abdDsv ] [ -C calfile ] [ -n num ] [  -S  showprog  ]  [  [
299       start ] end ](
300       calendar  -r  [  -abdDrsv ] [ -C calfile ] [ -n num ] [ -S showprog ] [
301       start ]
302              Show events in the calendar.
303
304              With no arguments, show events from the start of today until the
305              end  of  the  next  working day after today.  In other words, if
306              today is Friday, Saturday, or Sunday, show up to the end of  the
307              following Monday, otherwise show today and tomorrow.
308
309              If  end  is given, show events from the start of today up to the
310              time and date given, which is in the  format  described  in  the
311              previous  section.   Note  that  if  this  is a date the time is
312              assumed to be midnight at the start of the date, so that  effec‐
313              tively this shows all events before the given date.
314
315              end may start with a +, in which case the remainder of the spec‐
316              ification is a relative time format as described in the previous
317              section indicating the range of time from the start time that is
318              to be included.
319
320              If start is also given, show events starting from that time  and
321              date.  The word now can be used to indicate the current time.
322
323              To  implement  an alert when events are due, include calendar -s
324              in your ~/.zshrc file.
325
326              Options:
327
328              -a     Show all items in the calendar, regardless of  the  start
329                     and end.
330
331              -b     Brief:   don't  display continuation lines (i.e. indented
332                     lines following the line with the  date/time),  just  the
333                     first line.
334
335              -B lines
336                     Brief:  display at most the first lines lines of the cal‐
337                     endar entry.  `-B 1' is equivalent to `-b'.
338
339              -C calfile
340                     Explicitly specify a calendar file instead of  the  value
341                     of the calendar-file style or the the default ~/calendar.
342
343              -d     Move  any  events that have passed from the calendar file
344                     to the "done" file, as given by the  done-file  style  or
345                     the  default  which  is  the  calendar  file  with  .done
346                     appended.  This option is implied by the -s option.
347
348              -D     Turns off the option -d, even if the -s  option  is  also
349                     present.
350
351              -n num, -num
352                     Show  at  least  num  events,  if present in the calendar
353                     file, regardless of the start and end.
354
355              -r     Show all the remaining options in the calendar,  ignoring
356                     the  given  end  time.   The start time is respected; any
357                     argument given is treated as a start time.
358
359              -s     Use the shell's sched command to schedule a  timed  event
360                     that  will warn the user when an event is due.  Note that
361                     the sched command only runs if the shell is at an  inter‐
362                     active  prompt;  a  foreground  task blocks the scheduled
363                     task from running until it is finished.
364
365                     The timed event usually runs the programme  calendar_show
366                     to  show  the  event, as described in the section UTILITY
367                     FUNCTIONS below.
368
369                     By default, a warning of the event is shown five  minutes
370                     before  it  is due.  The warning period can be configured
371                     by the style warn-time or for a single calendar entry  by
372                     including  WARN  reltime  in the first line of the entry,
373                     where reltime is one of the usual relative time formats.
374
375                     A repeated event may be indicated by including  RPT  rel‐
376                     date in the first line of the entry.  After the scheduled
377                     event has been displayed it will be re-entered  into  the
378                     calendar file at a time reldate after the existing event.
379                     Note that this is currently the  only  use  made  of  the
380                     repeat  count,  so  that  it is not possible to query the
381                     schedule for a recurrence of an  event  in  the  calendar
382                     until the previous event has passed.
383
384                     It  is  safe to run calendar -s to reschedule an existing
385                     event (if the calendar file has  changed,  for  example),
386                     and also to have it running in multiples instances of the
387                     shell since the calendar file is locked when in use.
388
389                     By default, expired events are moved to the "done"  file;
390                     see the -d option.  Use -D to prevent this.
391
392              -S showprog
393                     Explicitly  specify  a  programme  to be used for showing
394                     events instead of the value of the show-prog style or the
395                     default calendar_show.
396
397              -v     Verbose:   show more information about stages of process‐
398                     ing.  This is useful for confirming that the function has
399                     successfully parsed the dates in the calendar file.
400
401       calendar_add [ -BL ] event ...
402              Adds a single event to the calendar in the appropriate location.
403              The event can contain multiple lines, as described in  the  sec‐
404              tion  Calendar  File  Format above.  Using this function ensures
405              that the calendar file is sorted in date  and  time  order.   It
406              also makes special arrangements for locking the file while it is
407              altered.  The old calendar is left in a  file  with  the  suffix
408              .old.
409
410              The  option  -B indicates that backing up the calendar file will
411              be handled by the caller and should not be performed  by  calen‐
412              dar_add.   The  option  -L  indicates that calendar_add does not
413              need to lock the calendar file as it is already  locked.   These
414              options will not usually be needed by users.
415
416              If the style reformat-date is true, the date and time of the new
417              entry will be rewritten into the standard date format:  see  the
418              descriptions of this style and the style date-format.
419
420              The  function can use a unique identifier stored with each event
421              to ensure that updates to existing events are treated correctly.
422              The  entry  should contain the word UID, followed by whitespace,
423              followed by a word consisting entirely of hexadecimal digits  of
424              arbitrary  length (all digits are significant, including leading
425              zeroes).  As the UID is not directly useful to the user,  it  is
426              convenient  to hide it on an indented continuation line starting
427              with a #, for example:
428
429                     Aug 31, 2007 09:30  Celebrate the end of the holidays
430                       # UID 045B78A0
431
432              The second line will not be shown by the calendar function.
433
434       calendar_edit
435              This calls the user's editor to edit  the  calendar  file.   The
436              editor  is  given by the variable VISUAL, if set, else the vari‐
437              able EDITOR.  If the calendar scheduler was running, then  after
438              editing the file calendar -s is called to update it.
439
440              This  function  locks  out  the calendar system during the edit.
441              Hence it should be used to edit the calendar file  if  there  is
442              any possibility of a calendar event occurring meanwhile.
443
444       calendar_parse calendar-entry
445              This  is the internal function that analyses the parts of a cal‐
446              endar entry, which is passed as the only argument.  The function
447              returns status 1 if the argument could not be parsed as a calen‐
448              dar entry and status 2 if the wrong  number  of  arguments  were
449              passed; it also sets the parameter reply to an empty associative
450              array.  Otherwise, it returns status 0 and sets elements of  the
451              associative array reply as follows:
452       time   The  time  as a string of digits in the same units as $EPOCHSEC‐
453              ONDS
454       text1  The text from the line not including the date and  time  of  the
455              event, but including any WARN or RPT keywords and values.
456       warntime
457              Any warning time given by the WARN keyword as a string of digits
458              containing the time at which  to  warn  in  the  same  units  as
459              $EPOCHSECONDS.  (Note this is an absolute time, not the relative
460              time passed down.)  Not set  no  WARN  keyword  and  value  were
461              matched.
462       warnstr
463              The raw string matched after the WARN keyword, else unset.
464       rpttime
465              Any recurrence time given by the RPT keyword as a string of dig‐
466              its containing the time of the recurrence in the same  units  as
467              $EPOCHSECONDS.   (Note this is an absolute time.)  Not set if no
468              RPT keyword and value were matched.
469       rptstr The raw string matched after the RPT keyword, else unset.
470       text2  The text from the line after removal of the date  and  any  key‐
471              words and values.  )
472
473       calendar_showdate [ -r ] [ -f fmt ] date-spec ...
474              The  given  date-spec  is interpreted and the corresponding date
475              and time printed.  If the initial date-spec begins with a + or -
476              it  is treated as relative to the current time; date-specs after
477              the first are treated as relative to the date calculated so  far
478              and  a  leading  + is optional in that case.  This allows one to
479              use the system  as  a  date  calculator.   For  example,  calen‐
480              dar_showdate  '+1 month, 1st Friday' shows the date of the first
481              Friday of next month.
482
483              With the option -r nothing is printed but the value of the  date
484              and  time  in seconds since the epoch is stored in the parameter
485              REPLY.
486
487              With the option -f fmt the given date/time conversion format  is
488              passed to strftime; see notes on the date-format style below.
489
490              In order to avoid ambiguity with negative relative date specifi‐
491              cations, options must occur in separate words; in  other  words,
492              -r and -f should not be combined in the same word.
493
494       calendar_sort
495              Sorts  the  calendar  file  into date and time order.    The old
496              calendar is left in a file with the suffix .old.
497
498   Glob qualifiers
499       The function age can be autoloaded and use separately from the calendar
500       system,  although  it uses the function calendar_scandate for date for‐
501       matting.  It requires the zsh/stat builtin, which makes  available  the
502       builtin stat.  This may conflict with an external programme of the same
503       name; if it does, the builtin may be disabled for normal  operation  by
504       including the following code in an initialization file:
505
506              zmodload -i zsh/stat
507              disable stat
508
509       age  selects  files  having a given modification time for use as a glob
510       qualifier.  The format of the date is the same as  that  understood  by
511       the  calendar  system,  described  in the section FILE AND DATE FORMATS
512       above.
513
514       The function can take one or  two  arguments,  which  can  be  supplied
515       either directly as command or arguments, or separately as shell parame‐
516       ters.
517
518              print *(e:age 2006/10/04 2006/10/09:)
519
520       The example above matches all files modified between the start of those
521       dates.  The second argument may alternatively be a relative time intro‐
522       duced by a +:
523
524              print *(e:age 2006/10/04 +5d:)
525
526       The example above is equivalent to the previous example.
527
528       In addition to the special use of days of the week, today  and  yester‐
529       day,  times with no date may be specified; these apply to today.  Obvi‐
530       ously such uses become problematic around midnight.
531
532              print *(e-age 12:00 13:30-)
533
534       The example above shows files modified between 12:00 and 13:00 today.
535
536              print *(e:age 2006/10/04:)
537
538       The example above matches all files modified on that date.  If the sec‐
539       ond  argument  is  omitted it is taken to be exactly 24 hours after the
540       first argument (even if the first argument contains a time).
541
542              print *(e-age 2006/10/04:10:15 2006/10/04:10:45-)
543
544       The example above supplies times.  Note that whitespace within the time
545       and  date  specification must be quoted to ensure age receives the cor‐
546       rect arguments, hence the use of the additional colon to  separate  the
547       date and time.
548
549              AGEREF1=2006/10/04:10:15
550              AGEREF2=2006/10/04:10:45
551              print *(+age)
552
553       This shows the same example before using another form of argument pass‐
554       ing.  The dates and times in the parameters AGEREF1 and AGEREF2 stay in
555       effect until unset, but will be overridden if any argument is passed as
556       an explicit argument to age.  Any explicit argument causes both parame‐
557       ters to be ignored.
558

STYLES

560       The zsh style mechanism using the zstyle command is describe in zshmod‐
561       ules(1).  This is the same mechanism used in the completion system.
562
563       The styles below are all examined in the  context  :datetime:function:,
564       for example :datetime:calendar:.
565
566       calendar-file
567              The location of the main calendar.  The default is ~/calendar.
568
569       date-format
570              A  strftime  format string (see strftime(3)) with the zsh exten‐
571              sions providing various numbers with no leading zero or space if
572              the  number  is  a  single digit as described for the %D{string}
573              prompt format in the section EXPANSION OF  PROMPT  SEQUENCES  in
574              zshmisc(1).
575
576              This  is  used for outputting dates in calendar, both to support
577              the -v option and when adding recurring events back to the  cal‐
578              endar file, and in calendar_showdate as the final output format.
579
580              If  the  style is not set, the default used is similar the stan‐
581              dard system format as output by the date command (also known  as
582              `ctime format'): `%a %b %d %H:%M:%S %Z %Y'.
583
584       done-file
585              The  location  of the file to which events which have passed are
586              appended.  The default is the calendar file  location  with  the
587              suffix  .done.  The style may be set to an empty string in which
588              case a "done" file will not be maintained.
589
590       reformat-date
591              Boolean, used by calendar_add.  If it is true, the date and time
592              of  new entries added to the calendar will be reformatted to the
593              format given by the style date-format or its default.  Only  the
594              date and time of the event itself is reformatted; any subsidiary
595              dates and times such as those associated with repeat and warning
596              times are left alone.
597
598       show-prog
599              The  programme  run  by calendar for showing events.  It will be
600              passed the start time and stop time of the events  requested  in
601              seconds  since  the epoch followed by the event text.  Note that
602              calendar -s uses a start time and stop time equal to one another
603              to indicate alerts for specific events.
604
605              The default is the function calendar_show.
606
607       warn-time
608              The  time  before an event at which a warning will be displayed,
609              if the first line of the event does not include the  text  EVENT
610              reltime.  The default is 5 minutes.
611

UTILITY FUNCTIONS

613       calendar_lockfiles
614              Attempt  to  lock  the  files given in the argument.  To prevent
615              problems with network file locking this is done  in  an  ad  hoc
616              fashion by attempting to create a symbolic link to the file with
617              the name file.lockfile.  No other  system  level  functions  are
618              used  for locking, i.e. the file can be accessed and modified by
619              any utility that does not use this  mechanism.   In  particular,
620              the  user is not prevented from editing the calendar file at the
621              same time unless calendar_edit is used.
622
623              Three attempts are made to lock the file before giving  up.   If
624              the  module  zsh/zselect is available, the times of the attempts
625              are jittered so that multiple instances of the calling  function
626              are unlikely to retry at the same time.
627
628              The  files  locked  are  appended  to the array lockfiles, which
629              should be local to the caller.
630
631              If all files were successfully locked, status zero is  returned,
632              else status one.
633
634              This  function  may  be used as a general file locking function,
635              although this will only work if only this mechanism is  used  to
636              lock files.
637
638       calendar_read
639              This  is  a backend used by various other functions to parse the
640              calendar file, which is passed as the only argument.  The  array
641              calendar_entries  is  set  to the list of events in the file; no
642              pruning is done except that  ampersands  are  removed  from  the
643              start of the line.  Each entry may contain multiple lines.
644
645       calendar_scandate
646              This  is a generic function to parse dates and times that may be
647              used separately from the calendar system.   The  argument  is  a
648              date  or time specification as described in the section FILE AND
649              DATE FORMATS above.  The parameter REPLY is set to the number of
650              seconds  since the epoch corresponding to that date or time.  By
651              default, the date and time may occur anywhere within  the  given
652              argument.
653
654              Returns  status  zero  if  the  date  and time were successfully
655              parsed, else one.
656
657              Options:
658              -a     The date and time are anchored to the start of the  argu‐
659                     ment;  they  will  not  be  matched if there is preceding
660                     text.
661
662              -A     The date and time are anchored to both the start and  end
663                     of  the  argument; they will not be matched if the is any
664                     other text in the argument.
665
666              -d     Enable additional debugging output.
667
668              -m     Minus.  When -R anchor_time is also  given  the  relative
669                     time is calculated backwards from anchor_time.
670
671              -r     The argument passed is to be parsed as a relative time.
672
673              -R anchor_time
674                     The  argument  passed is to be parsed as a relative time.
675                     The time is relative to anchor_time, a  time  in  seconds
676                     since  the  epoch, and the returned value is the absolute
677                     time corresponding to advancing anchor_time by the  rela‐
678                     tive  time  given.   This  allows lengths of months to be
679                     correctly taken into account.  If the final day does  not
680                     exist in the given month, the last day of the final month
681                     is given.  For example, if the anchor time is during 31st
682                     January  2007 and the relative time is 1 month, the final
683                     time is the same time of day during 28th February 2007.
684
685              -s     In addition to setting REPLY, set REPLY2 to the remainder
686                     of  the  argument  after  the  date  and  time  have been
687                     stripped.  This is empty if the option -A was given.
688
689              -t     Allow a time with no date  specification.   The  date  is
690                     assumed to be today.  The behaviour is unspecified if the
691                     iron tongue of midnight is tolling twelve.
692
693       calendar_show
694              The function used by default to display events.   It  accepts  a
695              start  time  and end time for events, both in epoch seconds, and
696              an event description.
697
698              The event is always printed to standard output.  If the  command
699              line  editor is active (which will usually be the case) the com‐
700              mand line will be redisplayed after the output.
701
702              If the parameter DISPLAY is set and the start and end times  are
703              the  same  (indicating a scheduled event), the function uses the
704              command xmessage to display a window with the event details.
705

BUGS

707       As the system is based entirely on shell functions (with a little  sup‐
708       port  from  the  zsh/datetime  module)  the  mechanisms used are not as
709       robust as those provided by a dedicated calendar utility.  Consequently
710       the user should not rely on the shell for vital alerts.
711
712       There is no calendar_delete function.
713
714       There  is  no localization support for dates and times, nor any support
715       for the use of time zones.
716
717       Relative periods of months and years do not take into account the vari‐
718       able number of days.
719
720       The  calendar_show  function is currently hardwired to use xmessage for
721       displaying alerts on X Window System displays.  This should be  config‐
722       urable and ideally integrate better with the desktop.
723
724       calendar_lockfiles  hangs the shell while waiting for a lock on a file.
725       If called from a scheduled task, it should instead reschedule the event
726       that caused it.
727
728
729
730zsh 4.3.10                       June 1, 2009                     ZSHCALSYS(1)
Impressum