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 --locale=LOCALE
67 Format results according to LOCALE, this would only affect month
68 and weekday names.
69
70 --from-locale=LOCALE
71 Interpret dates on stdin or the command line as coming from the
72 locale LOCALE, this would only affect month and weekday names as
73 input formats have to be specified explicitly.
74
75 --from-zone=ZONE
76 Interpret dates on stdin or the command line as coming from the
77 time zone ZONE.
78
79 -z, --zone=ZONE
80 Convert dates printed on stdout to time zone ZONE, default: UTC.
81
83 Format specs in dateutils are similar to posix' strftime().
84
85 However, due to a broader range of supported calendars dateutils must
86 employ different rules.
87
88 Date specs:
89 %a The abbreviated weekday name
90 %A The full weekday name
91 %_a The weekday name shortened to a single character (MTWRFAS)
92 %b The abbreviated month name
93 %B The full month name
94 %_b The month name shortened to a single character (FGHJKMNQUVXZ)
95 %c The count of the weekday within the month (range 00 to 05)
96 %C The count of the weekday within the year (range 00 to 53)
97 %d The day of the month, 2 digits (range 00 to 31)
98 %D The day of the year, 3 digits (range 000 to 366)
99 %F Equivalent to %Y-%m-%d (ymd's canonical format)
100 %g ISO week date year without the century (range 00 to 99)
101 %G ISO week date year including the century
102 %j Equivalent to %D
103 %m The month in the current calendar (range 00 to 19)
104 %Q The quarter of the year (range Q1 to Q4)
105 %q The number of the quarter (range 01 to 04)
106 %s The number of seconds since the Epoch.
107 %u The weekday as number (range 01 to 07, Sunday being 07)
108 %U The week count, day of week is Sun (range 00 to 53)
109 %V The ISO week count, day of week is Mon (range 01 to 53)
110 %w The weekday as number (range 00 to 06, Sunday being 00)
111 %W The week count, day of week is Mon (range 00 to 53)
112 %y The year without a century (range 00 to 99)
113 %Y The year including the century
114 %_y The year shortened to a single digit
115 %Z The zone offset in hours and minutes (HH:MM) with
116 a preceding sign (+ for offsets east of UTC, - for offsets
117 west of UTC)
118
119 %Od The day as roman numerals
120 %Om The month as roman numerals
121 %Oy The two digit year as roman numerals
122 %OY The year including the century as roman numerals
123
124 %rs In time systems whose Epoch is different from the unix Epoch, this
125 selects the number of seconds since then.
126 %rY In calendars with years that don't coincide with the Gregorian
127 years, this selects the calendar's year.
128
129 %dth The day of the month as an ordinal number, 1st, 2nd, 3rd, etc.
130 %mth The month of the year as an ordinal number, 1st, 2nd, 3rd, etc.
131
132 %db The business day of the month (since last month's ultimo)
133 %dB Number of business days until this month's ultimo
134
135 Time specs:
136 %H The hour of the day using a 24h clock, 2 digits (range 00 to 23)
137 %I The hour of the day using a 12h clock, 2 digits (range 01 to 12)
138 %M The minute (range 00 to 59)
139 %N The nanoseconds (range 000000000 to 999999999)
140 %p The string AM or PM, noon is PM and midnight is AM.
141 %P Like %p but in lowercase
142 %S The (range 00 to 60, 60 is for leap seconds)
143 %T Equivalent to %H:%M:%S
144
145 General specs:
146 %n A newline character
147 %t A tab character
148 %% A literal % character
149
150 Modifiers:
151 %O Modifier to turn decimal numbers into Roman numerals
152 %r Modifier to turn units into real units
153 %0 Modifier to turn on zero prefixes
154 %SPC Modifier to turn on space prefixes
155 %- Modifier to turn off prefixes altogether
156 th Suffix, read and print ordinal numbers
157 b Suffix, treat days as business days
158
159 By design dates before 1601-01-01 are not supported.
160
161 For conformity here is a list of calendar designators and their corre‐
162 sponding format string:
163 ymd %Y-%m-%d
164 ymcw %Y-%m-%c-%w
165 ywd %rY-W%V-%u
166 bizda %Y-%m-%db
167 lilian n/a
168 ldn n/a
169 julian n/a
170 jdn n/a
171 matlab n/a
172 mdn n/a
173
174 These designators can be used as output format string, moreover,
175 @code{lilian}/@code{ldn} and @code{julian}/@code{jdn} can also be used
176 as input format string.
177
178
180 Some tools ("dateadd", "dateseq") need durations as their input. Dura‐
181 tions are generally incompatible with input formats as specified by
182 "-i|--input-format" and (at the moment) the input syntax is fixed.
183
184 The general format is "+-Nunit" where "+" or "-" is the sign, "N" a
185 number, and "unit" the unit as discussed below.
186
187 Units:
188 s seconds
189 m minutes
190 h hours
191 rs real-life seconds, as in including leap transitions
192
193 d days
194 b business days
195 mo months
196 y years
197
198 For historical reasons, we used to accept "m" in the context of date-
199 only input as a qualifier for months. As of 0.4.4, this is no longer
200 the case.
201
202
204 $ dateadd 2012-03-01 1d
205 2012-03-02
206 $
207
208 $ dateadd 2012-03-01 1mo
209 2012-04-01
210 $
211
212 $ dateadd 2012-03-31 1mo
213 2012-04-30
214 $
215
216 $ dateadd 2w2d <<EOF
217 2012-03-01
218 2012-03-02
219 2012-03-04
220 2012-03-08
221 2012-03-16
222 EOF
223 2012-03-17
224 2012-03-18
225 2012-03-20
226 2012-03-24
227 2012-04-01
228 $
229
230 $ dateadd 10:01:00 1h6m
231 11:07:00
232 $
233
234 $ dateadd 10:01:00 -1h6m
235 08:55:00
236 $
237
238 $ dateadd 10:01:00 3605s
239 11:01:05
240 $
241
243 Written by Sebastian Freundt <freundt@fresse.org>
244
246 Report bugs to: https://github.com/hroptatyr/dateutils/issues
247
249 The full documentation for dateadd is maintained as a Texinfo manual.
250 If the info and dateadd programs are properly installed at your site,
251 the command
252
253 info (dateutils)dateadd
254
255 should give you access to the complete manual.
256
257
258
259dateutils 0.4.4 August 2018 DATEADD(1)