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
date
isn’t provided in the arguments, it’s read from/dev/stdin
instead.
- 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
parse
command 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
parse
command.
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
stamp1
tostamp2
, and returns whetherstamp1
containsstamp2
.
- overlaps [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
overlaps withstamp2
.
- abuts [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
abutsstamp2
.
- same [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
is the same asstamp2
.
- shorter [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
is shorter thanstamp2
.
- same-duration [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
is the same duration asstamp2
.
- longer [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
is longer thanstamp2
.
- before [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
is beforestamp2
.
- start-before [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
starts beforestamp2
.
- end-before [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
ends beforestamp2
.
- during [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
is duringstamp2
.
- start-during [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
starts duringstamp2
.
- end-during [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
ends duringstamp2
.
- after [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
is afterstamp2
.
- start-after [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
starts afterstamp2
.
- end-after [<stamp1> [<stamp2>]]
- - stamp1
The value to compare.
- - stamp2
The value to compare the other to.
Compares
stamp1
tostamp2
, and returns whetherstamp1
ends 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
Calends
value, usingcalendar
to select a calendar system, andformat
to describe the contents ofdate
to 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
Calends
value, usingcalendar
to select a calendar system, andformat
to describe the contents ofdate
andend-date
to 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
Calends
value to use.
Retrieves the start date of
source
as 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
Calends
value to use.
Retrieves the end date of
source
as 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
Calends
value to use.- - target
The name to give the result.
Sets the start date of
target
based 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
Calends
value to use.- - target
The name to give the result.
Sets the end date of
target
based 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
Calends
value 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
Calends
value 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
Calends
value 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
Calends
value 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
Calends
value to use.- - target
The name to give the result.
Sets
target
to aCalends
value ofoffset
duration (as interpreted by the calendar system given incalendar
), which abuts the end ofsource
. Ifoffset
is empty,calendar
is 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
Calends
value to use.- - target
The name to give the result.
Sets
target
to aCalends
value ofoffset
duration (as interpreted by the calendar system given incalendar
), which abuts the start ofsource
. Ifoffset
is empty,calendar
is ignored, andsource
’s duration is used instead.
Combine
- merge <source> <combine> <target>
- - source
The name of the
Calends
value to use.- - combine
The
Calends
value to merge.- - target
The name to give the result.
Sets
target
to a value spanning from the earliest start date to the latest end date betweensource
andcombine
.
- intersect <source> <combine> <target>
- - source
The name of the
Calends
value to use.- - combine
The
Calends
value to intersect.- - target
The name to give the result.
Sets
target
to a value spanning the overlap betweensource
andcombine
. Ifsource
andcombine
don’t overlap, returns an error.
- gap <source> <combine> <target>
- - source
The name of the
Calends
value to use.- - combine
The
Calends
value to gap.- - target
The name to give the result.
Sets
target
to a value spanning the gap betweensource
andcombine
. Ifsource
andcombine
overlap (and there is, therefore, no gap to return), returns an error.
Compare
- difference <source> <compare> <mode>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.- - mode
The comparison mode.
Returns the difference of
source
minuscompare
, usingmode
to select which values to use in the calculation. Validmode
s include:start
- use the start date of bothsource
andcompare
duration
- use the duration of bothsource
andcompare
end
- use the end date of bothsource
andcompare
start-end
- use the start ofsource
, and the end ofcompare
end-start
- use the end ofsource
, and the start ofcompare
- compare <source> <compare> <mode>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.- - mode
The comparison mode.
Returns
-1
ifsource
is less thancompare
,0
if they are equal, and1
ifsource
is greater thancompare
, usingmode
to select which values to use in the comparison. Validmode
s are the same as fordifference
, above.
- contains <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Checks whether
source
contains all ofcompare
.
- overlaps <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Checks whether
source
overlaps withcompare
.
- abuts <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Checks whether
source
abutscompare
(that is, whether one begins at the same instant the other ends).
- is-same <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Checks whether
source
covers the same span of time ascompare
.
- is-shorter <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Compares the duration of
source
andcompare
.
- is-same-duration <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Compares the duration of
source
andcompare
.
- is-longer <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Compares the duration of
source
andcompare
.
- is-before <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Compares the entirety of
source
with the start date ofcompare
.
- starts-before <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Compares the start date of
source
with the start date ofcompare
.
- ends-before <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Compares the end date of
source
with the start date ofcompare
.
- is-during <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Checks whether the entirety of
source
lies between the start and end dates ofcompare
.
- starts-during <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Checks whether the start date of
source
lies between the start and end dates ofcompare
.
- ends-during <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Checks whether the end date of
source
lies between the start and end dates ofcompare
.
- is-after <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Compares the entirety of
source
with the end date ofcompare
.
- starts-after <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Compares the start date of
source
with the end date ofcompare
.
- ends-after <source> <compare>
- - source
The name of the
Calends
value to use.- - compare
The
Calends
value to compare.
Compares the end date of
source
with the end date ofcompare
.