Using Calends from the Command Line
Calends can be used from the command line directly, though some if its features are limited or unavailable. Specifically, it doesn’t support custom calendars, so you’ll need to ensure you build it with the calendar you want already loaded.
Command Line Options
The available options for calends, on the command line directly, are the
following:
- convert <from-calendar> <from-format> <to-calendar> <to-format> [<date>]
- - from-calendar
The calendar system to parse the date/time with.
- - from-format
The format the date/time is expected to use.
- - to-calendar
The calendar system to format the date/time with.
- - to-format
The format the date/time is expected to use.
- - date
The value to convert.
Converts a date from one calendar/format to another. If
dateisn’t provided in the arguments, it’s read from/dev/stdininstead.
- parse <from-calendar> <from-format> [<date>]
- - from-calendar
The calendar system to parse the date/time with.
- - from-format
The format the date/time is expected to use.
- - date
The value to parse.
Converts a date from the given calendar/format to a portable/unambiguous date stamp. The output from this command can then be used as input to others.
- format <to-calendar> <to-format> [<stamp>]
- - to-calendar
The calendar system to format the date/time with.
- - to-format
The format the date/time is expected to use.
- - stamp
The value to format.
Converts a date stamp from the
parsecommand to the given calendar/format.
- offset <offset-calendar> [<offset> [<stamp>]]
- - offset-calendar
The calendar system to interpret the offset with.
- - offset
The offset to add.
- - stamp
The value to add the offset to.
Adds an offset to the date stamp from the
parsecommand.
There is also a calends compare, whose options are these:
- contains [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1containsstamp2.
- overlaps [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1overlaps withstamp2.
- abuts [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1abutsstamp2.
- same [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1is the same asstamp2.
- shorter [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1is shorter thanstamp2.
- same-duration [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1is the same duration asstamp2.
- longer [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1is longer thanstamp2.
- before [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1is beforestamp2.
- start-before [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1starts beforestamp2.
- end-before [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1ends beforestamp2.
- during [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1is duringstamp2.
- start-during [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1starts duringstamp2.
- end-during [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1ends duringstamp2.
- after [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1is afterstamp2.
- start-after [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1starts afterstamp2.
- end-after [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1tostamp2, and returns whetherstamp1ends afterstamp2.
Interactive/Batch Mode
Create
- parse <calendar> <format> <date> <target>
- - calendar
The calendar system to parse the date/time with.
- - format
The format the date/time is expected to use.
- - date
The value to parse.
- - target
The name to give the result.
Creates a new
Calendsvalue, usingcalendarto select a calendar system, andformatto describe the contents ofdateto parse. The result is stored astarget, so it can be used later on by other commands.
- parse-range <calendar> <format> <date> <end-date> <target>
- - calendar
The calendar system to parse the dates/times with.
- - format
The format the dates/times are expected to use.
- - date
The start date to parse.
- - end-date
The end date to parse.
- - target
The name to give the result.
Creates a new
Calendsvalue, usingcalendarto select a calendar system, andformatto describe the contents ofdateandend-dateto parse. The result is stored astarget, so it can be used later on by other commands.
Read
- date <calendar> <format> <source>
- - calendar
The calendar system to format the date/time with.
- - format
The format the date/time is expected to be in.
- - source
The name of the
Calendsvalue to use.
Retrieves the start date of
sourceas a string. The value is generated by the calendar system given incalendar, according to the format string informat.
- end-date <calendar> <format> <source>
- - calendar
The calendar system to format the date/time with.
- - format
The format the date/time is expected to be in.
- - source
The name of the
Calendsvalue to use.
Retrieves the end date of
sourceas a string. The value is generated by the calendar system given incalendar, according to the format string informat.
Update
- set-date <calendar> <format> <date> <source> <target>
- - calendar
The calendar system to parse the date/time with.
- - format
The format the date/time is expected to use.
- - date
The value to parse the date/time from.
- - source
The name of the
Calendsvalue to use.- - target
The name to give the result.
Sets the start date of
targetbased onsource’s current value. The inputs are the same as forparse, above.
- set-end-date <calendar> <format> <date> <source> <target>
- - calendar
The calendar system to parse the date/time with.
- - format
The format the date/time is expected to use.
- - date
The value to parse the date/time from.
- - source
The name of the
Calendsvalue to use.- - target
The name to give the result.
Sets the end date of
targetbased onsource’s current value. The inputs are the same as forparse, above.
Manipulate
- add <calendar> <offset> <source> <target>
- - calendar
The calendar system to parse the offset with.
- - offset
The value to parse the offset from.
- - source
The name of the
Calendsvalue to use.- - target
The name to give the result.
Increases the end date of
source’s current value byoffset, as interpreted by the calendar system given incalendar.
- add-from-end <calendar> <offset> <source> <target>
- - calendar
The calendar system to parse the offset with.
- - offset
The value to parse the offset from.
- - source
The name of the
Calendsvalue to use.- - target
The name to give the result.
Increases the start date of
source’s current value byoffset, as interpreted by the calendar system given incalendar.
- subtract <calendar> <offset> <source> <target>
- - calendar
The calendar system to parse the offset with.
- - offset
The value to parse the offset from.
- - source
The name of the
Calendsvalue to use.- - target
The name to give the result.
Works the same as
add, except it decreases the start date, rather than increasing it.
- subtract-from-end <calendar> <offset> <source> <target>
- - calendar
The calendar system to parse the offset with.
- - offset
The value to parse the offset from.
- - source
The name of the
Calendsvalue to use.- - target
The name to give the result.
Works the same as
add-from-end, except it decreases the end date, rather than increasing it.
- next <calendar> <offset> <source> <target>
- - calendar
The calendar system to parse the offset with.
- - offset
The value to parse the offset from.
- - source
The name of the
Calendsvalue to use.- - target
The name to give the result.
Sets
targetto aCalendsvalue ofoffsetduration (as interpreted by the calendar system given incalendar), which abuts the end ofsource. Ifoffsetis empty,calendaris ignored, andsource’s duration is used instead.
- previous <calendar> <offset> <source> <target>
- - calendar
The calendar system to parse the offset with.
- - offset
The value to parse the offset from.
- - source
The name of the
Calendsvalue to use.- - target
The name to give the result.
Sets
targetto aCalendsvalue ofoffsetduration (as interpreted by the calendar system given incalendar), which abuts the start ofsource. Ifoffsetis empty,calendaris ignored, andsource’s duration is used instead.
Combine
- merge <source> <combine> <target>
- - source
The name of the
Calendsvalue to use.- - combine
The
Calendsvalue to merge.- - target
The name to give the result.
Sets
targetto a value spanning from the earliest start date to the latest end date betweensourceandcombine.
- intersect <source> <combine> <target>
- - source
The name of the
Calendsvalue to use.- - combine
The
Calendsvalue to intersect.- - target
The name to give the result.
Sets
targetto a value spanning the overlap betweensourceandcombine. Ifsourceandcombinedon’t overlap, returns an error.
- gap <source> <combine> <target>
- - source
The name of the
Calendsvalue to use.- - combine
The
Calendsvalue to gap.- - target
The name to give the result.
Sets
targetto a value spanning the gap betweensourceandcombine. Ifsourceandcombineoverlap (and there is, therefore, no gap to return), returns an error.
Compare
- difference <source> <compare> <mode>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.- - mode
The comparison mode.
Returns the difference of
sourceminuscompare, usingmodeto select which values to use in the calculation. Validmodes include:start- use the start date of bothsourceandcompareduration- use the duration of bothsourceandcompareend- use the end date of bothsourceandcomparestart-end- use the start ofsource, and the end ofcompareend-start- use the end ofsource, and the start ofcompare
- compare <source> <compare> <mode>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.- - mode
The comparison mode.
Returns
-1ifsourceis less thancompare,0if they are equal, and1ifsourceis greater thancompare, usingmodeto select which values to use in the comparison. Validmodes are the same as fordifference, above.
- contains <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Checks whether
sourcecontains all ofcompare.
- overlaps <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Checks whether
sourceoverlaps withcompare.
- abuts <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Checks whether
sourceabutscompare(that is, whether one begins at the same instant the other ends).
- is-same <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Checks whether
sourcecovers the same span of time ascompare.
- is-shorter <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Compares the duration of
sourceandcompare.
- is-same-duration <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Compares the duration of
sourceandcompare.
- is-longer <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Compares the duration of
sourceandcompare.
- is-before <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Compares the entirety of
sourcewith the start date ofcompare.
- starts-before <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Compares the start date of
sourcewith the start date ofcompare.
- ends-before <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Compares the end date of
sourcewith the start date ofcompare.
- is-during <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Checks whether the entirety of
sourcelies between the start and end dates ofcompare.
- starts-during <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Checks whether the start date of
sourcelies between the start and end dates ofcompare.
- ends-during <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Checks whether the end date of
sourcelies between the start and end dates ofcompare.
- is-after <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Compares the entirety of
sourcewith the end date ofcompare.
- starts-after <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Compares the start date of
sourcewith the end date ofcompare.
- ends-after <source> <compare>
- - source
The name of the
Calendsvalue to use.- - compare
The
Calendsvalue to compare.
Compares the end date of
sourcewith the end date ofcompare.