* doc/coreutils.texi (date invocation): Document %q.
* src/date.c (usage): Likewise.
* tests/misc/date.pl: Add a test case.
* cfg.mk (sc_strftime_check): Adjust to allow %q.
* NEWS: Mention the new feature.
date now accepts the --debug option, to annotate the parsed date string,
display timezone information, and warn about potential misuse.
+ date now accepts the %q format to output the quarter of the year.
+
* Noteworthy changes in release 8.25 (2016-01-20) [stable]
$(_sc_search_regexp)
# Ensure that date's --help output stays in sync with the info
-# documentation for GNU strftime. The only exception is %N,
+# documentation for GNU strftime. The only exception is %N and %q,
# which date accepts but GNU strftime does not.
extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
sc_strftime_check:
@if test -f $(srcdir)/src/date.c; then \
grep '^ %. ' $(srcdir)/src/date.c | sort \
| $(extract_char) > $@-src; \
- { echo N; \
+ { echo N; echo q; \
info libc date calendar format 2>/dev/null \
| grep "^ *['\`]%.'$$"| $(extract_char); }| sort >$@-info;\
if test $$(stat --format %s $@-info) != 2; then \
day of year (@samp{001}@dots{}@samp{366})
@item %m
month (@samp{01}@dots{}@samp{12})
+@item %q
+quarter of year (@samp{1}@dots{}@samp{4})
@item %u
day of week (@samp{1}@dots{}@samp{7}) with @samp{1} corresponding to Monday
@item %U
%N nanoseconds (000000000..999999999)\n\
%p locale's equivalent of either AM or PM; blank if not known\n\
%P like %p, but lower case\n\
+ %q quarter of year (1..4)\n\
%r locale's 12-hour clock time (e.g., 11:11:04 PM)\n\
%R 24-hour hour and minute; same as %H:%M\n\
%s seconds since 1970-01-01 00:00:00 UTC\n\
['W92-2', "--date '1992-1-5' +%W", {OUT=>"00"}],
['W92-3', "--date '1992-1-6' +%W", {OUT=>"01"}],
+ ['q-1', "--date '1000-1-1' +%q", {OUT=>"1"}],
+ ['q-2', "--date '1000-4-1' +%q", {OUT=>"2"}],
+ ['q-3', "--date '1000-7-1' +%q", {OUT=>"3"}],
+ ['q-4', "--date '1000-10-1' +%q", {OUT=>"4"}],
+
['millen-1', "--date '1998-1-1 3 years' +%Y", {OUT=>"2001"}],
['rel-0', "-d '$d1 now' '+%Y-%m-%d %T'", {OUT=>"$d0 $t0"}],