1DATEADD(1) User Commands DATEADD(1)
2
3
4
6 dateadd - Add DURATION to DATE/TIME and print the result.
7
9 dateadd [OPTION]... [DATE/TIME] [DURATION]
10
12 Add DURATION to DATE/TIME and print the result. If DATE/TIME is omit‐
13 ted but DURATION is given, read a list of DATE/TIMEs from stdin. If
14 DURATION is omitted but DATE/TIME is given, read a list of DURATIONs
15 from stdin.
16
17 Durations are specified as nY, nMO, nW, or nD for years, months, weeks,
18 or days respectively, or nH, nM, nS for hours, minutes, and seconds,
19 where N is a (possibly negative) number. The unit symbols can be writ‐
20 ten lower-case as well (y, mo, w, d, h, m, s) and the unit symbol `d'
21 can be omitted.
22
23 Note that duration addition is not commutative!
24 2000-03-30 +1mo +1d -> 2000-05-01
25 2000-03-30 +1d +1mo -> 2000-04-30
26
27
28 Recognized OPTIONs:
29
30 -h, --help
31 Print help and exit
32
33 -V, --version
34 Print version and exit
35
36 -q, --quiet
37 Suppress message about date/time and duration parser errors and
38 fix-ups. The default is to print a warning or the fixed up
39 value and return error code 2.
40
41 -f, --format=STRING
42 Output format. This can either be a specifier string (similar
43 to strftime()'s FMT) or the name of a calendar.
44
45 -i, --input-format=STRING...
46 Input format, can be used multiple times. Each date/time will
47 be passed to the input format parsers in the order they are
48 given, if a date/time can be read successfully with a given
49 input format specifier string, that value will be used.
50
51 -b, --base=DT
52 For underspecified input use DT as a fallback to fill in missing
53 fields. Also used for ambiguous format specifiers to position
54 their range on the absolute time line. Must be a date/time in
55 ISO8601 format. If omitted defaults to the current date/time.
56
57 -e, --backslash-escapes
58 Enable interpretation of backslash escapes in the output and
59 input format specifier strings.
60
61 -S, --sed-mode
62 Copy parts from the input before and after a matching date/time.
63 Note that all occurrences of date/times within a line will be
64 processed.
65
66 -E, --empty-mode
67 Empty lines that cannot be parsed.
68
69 --locale=LOCALE
70 Format results according to LOCALE, this would only affect month
71 and weekday names.
72
73 --from-locale=LOCALE
74 Interpret dates on stdin or the command line as coming from the
75 locale LOCALE, this would only affect month and weekday names as
76 input formats have to be specified explicitly.
77
78 --from-zone=ZONE
79 Interpret dates on stdin or the command line as coming from the
80 time zone ZONE.
81
82 -z, --zone=ZONE
83 Convert dates printed on stdout to time zone ZONE, default: UTC.
84
86 Format specs in dateutils are similar to posix' strftime().
87
88 However, due to a broader range of supported calendars dateutils must
89 employ different rules.
90
91 Date specs:
92 %a The abbreviated weekday name
93 %A The full weekday name
94 %_a The weekday name shortened to a single character (MTWRFAS)
95 %b The abbreviated month name
96 %B The full month name
97 %_b The month name shortened to a single character (FGHJKMNQUVXZ)
98 %c The count of the weekday within the month (range 00 to 05)
99 %C The count of the weekday within the year (range 00 to 53)
100 %d The day of the month, 2 digits (range 00 to 31)
101 %D The day of the year, 3 digits (range 000 to 366)
102 %F Equivalent to %Y-%m-%d (ymd's canonical format)
103 %g ISO week date year without the century (range 00 to 99)
104 %G ISO week date year including the century
105 %j Equivalent to %D
106 %m The month in the current calendar (range 00 to 19)
107 %Q The quarter of the year (range Q1 to Q4)
108 %q The number of the quarter (range 01 to 04)
109 %s The number of seconds since the Epoch.
110 %u The weekday as number (range 01 to 07, Sunday being 07)
111 %U The week count, day of week is Sun (range 00 to 53)
112 %V The ISO week count, day of week is Mon (range 01 to 53)
113 %w The weekday as number (range 00 to 06, Sunday being 00)
114 %W The week count, day of week is Mon (range 00 to 53)
115 %y The year without a century (range 00 to 99)
116 %Y The year including the century
117 %_y The year shortened to a single digit
118 %Z The zone offset in hours and minutes (HH:MM) with
119 a preceding sign (+ for offsets east of UTC, - for offsets
120 west of UTC)
121
122 %Od The day as roman numerals
123 %Om The month as roman numerals
124 %Oy The two digit year as roman numerals
125 %OY The year including the century as roman numerals
126
127 %rs In time systems whose Epoch is different from the unix Epoch, this
128 selects the number of seconds since then.
129 %rY In calendars with years that don't coincide with the Gregorian
130 years, this selects the calendar's year.
131
132 %dth The day of the month as an ordinal number, 1st, 2nd, 3rd, etc.
133 %mth The month of the year as an ordinal number, 1st, 2nd, 3rd, etc.
134
135 %db The business day of the month (since last month's ultimo)
136 %dB Number of business days until this month's ultimo
137
138 Time specs:
139 %H The hour of the day using a 24h clock, 2 digits (range 00 to 23)
140 %I The hour of the day using a 12h clock, 2 digits (range 01 to 12)
141 %M The minute (range 00 to 59)
142 %N The nanoseconds (range 000000000 to 999999999)
143 %p The string AM or PM, noon is PM and midnight is AM.
144 %P Like %p but in lowercase
145 %S The (range 00 to 60, 60 is for leap seconds)
146 %T Equivalent to %H:%M:%S
147
148 General specs:
149 %n A newline character
150 %t A tab character
151 %% A literal % character
152
153 Modifiers:
154 %O Modifier to turn decimal numbers into Roman numerals
155 %r Modifier to turn units into real units
156 %0 Modifier to turn on zero prefixes
157 %SPC Modifier to turn on space prefixes
158 %- Modifier to turn off prefixes altogether
159 th Suffix, read and print ordinal numbers
160 b Suffix, treat days as business days
161
162 By design dates before 1601-01-01 are not supported.
163
164 For conformity here is a list of calendar designators and their corre‐
165 sponding format string:
166 ymd %Y-%m-%d
167 ymcw %Y-%m-%c-%w
168 ywd %rY-W%V-%u
169 bizda %Y-%m-%db
170 lilian n/a
171 ldn n/a
172 julian n/a
173 jdn n/a
174 matlab n/a
175 mdn n/a
176
177 These designators can be used as output format string, moreover,
178 @code{lilian}/@code{ldn} and @code{julian}/@code{jdn} can also be used
179 as input format string.
180
181
183 Some tools ("dateadd", "dateseq") need durations as their input. Dura‐
184 tions are generally incompatible with input formats as specified by
185 "-i|--input-format" and (at the moment) the input syntax is fixed.
186
187 The general format is "+-Nunit" where "+" or "-" is the sign, "N" a
188 number, and "unit" the unit as discussed below.
189
190 Units:
191 s seconds
192 m minutes
193 h hours
194 rs real-life seconds, as in including leap transitions
195
196 d days
197 b business days
198 mo months
199 y years
200
201 For historical reasons, we used to accept "m" in the context of date-
202 only input as a qualifier for months. As of 0.4.4, this is no longer
203 the case.
204
205
207 $ dateadd 2012-03-01 1d
208 2012-03-02
209 $
210
211 $ dateadd 2012-03-01 1mo
212 2012-04-01
213 $
214
215 $ dateadd 2012-03-31 1mo
216 2012-04-30
217 $
218
219 $ dateadd 2w2d <<EOF
220 2012-03-01
221 2012-03-02
222 2012-03-04
223 2012-03-08
224 2012-03-16
225 EOF
226 2012-03-17
227 2012-03-18
228 2012-03-20
229 2012-03-24
230 2012-04-01
231 $
232
233 $ dateadd 10:01:00 1h6m
234 11:07:00
235 $
236
237 $ dateadd 10:01:00 -1h6m
238 08:55:00
239 $
240
241 $ dateadd 10:01:00 3605s
242 11:01:05
243 $
244
246 Written by Sebastian Freundt <freundt@fresse.org>
247
249 Report bugs to: https://github.com/hroptatyr/dateutils/issues
250
252 The full documentation for dateadd is maintained as a Texinfo manual.
253 If the info and dateadd programs are properly installed at your site,
254 the command
255
256 info (dateutils)dateadd
257
258 should give you access to the complete manual.
259
260
261
262dateutils 0.4.6 March 2019 DATEADD(1)