Durations
Taskwarrior supports duration values.
In the core, durations are used directly in one place - the recur attribute, used for recurring tasks.
For example, here is a recurring task that recurs every monday:
$ task add Take out the trash due:monday recur:weekly
The value monday is interpreted as ’next monday’, and the value weekly is interpreted as a 7-day duration.
The other place where durations are supported directly is with UDA attributes of type duration.
Relative Date
There is indirect support for durations everywhere that a date value is expected. For example, here is a task due in two days:
$ task add Birthday party due:2days
Whenever Taskwarrior expects a date (due date in this example) but instead finds a duration, it is interpreted as a relative duration added to the current date/time, in this example now + 2days.
Duration Format
5 secondsFive seconds.5 second5 secs5 sec5 s5seconds5second5secs5sec5ssecondOne second. Missing ordinal implies one second.sec5 minutesFive minutes.5 minute5 mins5 min5minutes5minute5mins5minminuteOne minute. Missing ordinal implies one minute.min3 hoursThree hours.3 hour3 hrs3 hr3 h3hours3hour3hrs3hr3hhourOne hour. Missing ordinal implies one hour.hr2 daysTwo days.2 day2 d2days2day2ddailyOne day. Missing ordinal implies one day.day3 weeksThree weeks.3 week3 wks3 wk3 w3weeks3week3wks3wk3wweeklyOne week. Missing ordinal implies one week.weekwkweekdaysEvery weekday, Monday to Friday.2 fortnightTwenty eight days.2 sennight2fortnight2sennightbiweeklyFourteen days. Missing ordinal implies fourteen days.fortnightsennight5 monthsFive months.5 month5 mnths5 mths5 mth5 mo5 m5months5month5mnths5mths5mth5mo5mmonthly30 days. Missing ordinal implies onemonthmonth. This is an imprecise value.mthmobimonthlySixty one days. Missing ordinal implies two months. This is an imprecise value.1 quarterlyNinety one days.1 quarters1 quarter1 qrtrs1 qrtr1 qtr1 q1quarterly1quarters1quarter1qrtrs1qrtr1qtr1qquarterlyNinety one days. Missing ordinal implies three months. This is an imprecise value.quarterqrtrqtrsemiannualOne hundred and eighty-three days. Missing ordinal implies six months. This is an imprecise value.1 yearsOne year.1 year1 yrs1 yr1 y1years1year1yrs1yr1yannualThree hundred and sixty-five days. Missing ordinal implies one year. This is an imprecise value.yearlyyearyrbiannualSeven hundred and thirty days. Missing ordinal implies two years. This is an imprecise value.biyearly
ISO-8601 Format
ISO-8601 defines a duration format which is supported by Taskwarrior. The format looks like this:
P[nY][nM][nD][T[nH][nM][nS]]
The format always begins with a ‘P’ (period).
The date elements ([nY][nM][nD]) are optional, as are the time elements ([nH][nM][nS]), but there must be one element specified.
Even though the month and minute values use the character ‘M’, there is no ambiguity because of the placement of the character ‘T’ which delineates date from time elements.
Here is a list of examples:
P3D- Three days.P1000D- One thousand days.P2M- Two months. This is an imprecise value.P2M3D- Two months and three days. This is an imprecise value.P1Y- One year. This is an imprecise value.P1Y3D- One year and three days. This is an imprecise value.P1Y2M- One year and two months. This is an imprecise value.P1Y2M3D- One year, two months and three days. This is an imprecise value.PT50S- Fifty seconds.PT40M- Forty minutes.PT40M50S- Forty minutes and fifty seconds.PT12H- Twelve hours.PT12H50S- Twelve hours and fifty seconds.PT12H40M- Twelve hours and forty minutes.PT12H40M50S- Twelve hours, forty minutes and fifty seconds.P1Y2M3DT12H40M50S- One year, two months, three days, twelve hours, forty minutes and fifty seconds. This is an imprecise value.
Precise values include days, hours, minutes, seconds. Year and month are not precise because they vary, and can only be made precise if the duration is anchored to a known date.