public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] strftime: support %q to output the quarter of year
@ 2016-11-03 19:46 Pádraig Brady
  2016-11-03 19:58 ` Florian Weimer
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Pádraig Brady @ 2016-11-03 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Pádraig Brady

This is already supported by gnulib.

* manual/time.texi: Document %q outputs quarter 1..4.
* time/strftime_l.c: Implement %q.
---
 manual/time.texi  | 6 ++++++
 time/strftime_l.c | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/manual/time.texi b/manual/time.texi
index 8a5f94e..f4c5f87 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -1510,6 +1510,12 @@ most locales @samp{AM}/@samp{PM} format is not supported, in such cases
 
 This format is a GNU extension.
 
+@item %q
+Quarter of the year (@samp{1}@dots{}@samp{4}),
+with January starting the first quarter.
+
+This format is a GNU extension.
+
 @item %r
 The complete calendar time using the AM/PM format of the current locale.
 
diff --git a/time/strftime_l.c b/time/strftime_l.c
index 869e0b9..13db490 100644
--- a/time/strftime_l.c
+++ b/time/strftime_l.c
@@ -1108,6 +1108,10 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
 	  goto underlying_strftime;
 #endif
 
+        case L_('q'):           /* GNU extension.  */
+          DO_SIGNED_NUMBER (1, tp->tm_mon < -3, tp->tm_mon / 3 + 1U);
+          break;
+
 	case L_('R'):
 	  subfmt = L_("%H:%M");
 	  goto subformat;
-- 
2.5.5

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-11-05  7:19 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-03 19:46 [PATCH] strftime: support %q to output the quarter of year Pádraig Brady
2016-11-03 19:58 ` Florian Weimer
2016-11-03 20:28   ` Adhemerval Zanella
2016-11-03 22:00   ` Joseph Myers
2016-11-04  1:47 ` Pádraig Brady
2016-11-04  4:12   ` Paul Eggert
2016-11-04 11:33 ` Rafal Luzynski
2016-11-04 14:27   ` [PATCH v3] strftime,strptime: have %q represent " Pádraig Brady
2016-11-04 11:41 ` [PATCH] strftime: support %q to output " Szabolcs Nagy
2016-11-04 12:00   ` Pádraig Brady
2016-11-04 12:08     ` Szabolcs Nagy
2016-11-04 12:23       ` Pádraig Brady
2016-11-04 12:41         ` Szabolcs Nagy
2016-11-04 12:58           ` Pádraig Brady
2016-11-04 13:12         ` keld
2016-11-04 14:12           ` Szabolcs Nagy
2016-11-04 14:57             ` Adhemerval Zanella
2016-11-05  7:19             ` keld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).