[glib/wip/carlosg/gdatetime-before-y1000: 1/2] glib: Format GDateTime ISO8601 years as %C%y
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/carlosg/gdatetime-before-y1000: 1/2] glib: Format GDateTime ISO8601 years as %C%y
- Date: Sun, 20 Mar 2022 12:35:52 +0000 (UTC)
commit b48cb29bcb6e19a06c67b4b29f41120348a7c912
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Mar 20 13:22:38 2022 +0100
glib: Format GDateTime ISO8601 years as %C%y
The current use of %Y does not take into account that %Y will
not pad the year with 0's, meanwhile ISO8601 does expect a full
YYYY format for all dates. This breaks the formatting with dates
prior to the year 1000.
Split this into %C%y so 2-digit, 0-padded century and year are
printed separately, this gives the expected YYYY format.
glib/gdatetime.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/glib/gdatetime.c b/glib/gdatetime.c
index 429cadefc..6299cdb11 100644
--- a/glib/gdatetime.c
+++ b/glib/gdatetime.c
@@ -3492,12 +3492,12 @@ g_date_time_format_iso8601 (GDateTime *datetime)
GString *outstr = NULL;
gchar *main_date = NULL;
gint64 offset;
- gchar *format = "%Y-%m-%dT%H:%M:%S";
+ gchar *format = "%C%y-%m-%dT%H:%M:%S";
/* if datetime has sub-second non-zero values below the second precision we
* should print them as well */
if (datetime->usec % G_TIME_SPAN_SECOND != 0)
- format = "%Y-%m-%dT%H:%M:%S.%f";
+ format = "%C%y-%m-%dT%H:%M:%S.%f";
/* Main date and time. */
main_date = g_date_time_format (datetime, format);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]