From 63ea8f1a2a603c356ad770ae7567246e7520f298 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 2 May 2023 10:27:31 +0200 Subject: build: Detect appropriate strftime() year modifier at build time Different libc implementations (or different platforms) have different bugs. Even though %Y is documented as a 4-digit number, and %C as year/100 in a [00-99] range, they both crap out with years under 1000, using respectively 3 and 1 digits. This would be typically task for a width modifier (e.g. %4Y, or %2C), but that was conversely found to break NixOS on Darwin. Since the existing libc bugs paint us to a corner, detect an appropriate modifier at build time to get a 4-digit year to get true ISO 8601 in our supported [0001-9999] year range. Closes: https://gitlab.gnome.org/GNOME/tracker/-/issues/402 --- src/libtracker-sparql/core/tracker-db-interface-sqlite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libtracker-sparql') diff --git a/src/libtracker-sparql/core/tracker-db-interface-sqlite.c b/src/libtracker-sparql/core/tracker-db-interface-sqlite.c index 2aa493ca9..25e2c519f 100644 --- a/src/libtracker-sparql/core/tracker-db-interface-sqlite.c +++ b/src/libtracker-sparql/core/tracker-db-interface-sqlite.c @@ -1624,9 +1624,9 @@ function_sparql_print_value (sqlite3_context *context, result_context_function_error (context, fn, "Invalid unix timestamp"); if (prop_type == TRACKER_PROPERTY_TYPE_DATETIME) - retval = strftime ((gchar *) &buf, sizeof (buf), "%2C%y-%m-%dT%TZ", &tm); + retval = strftime ((gchar *) &buf, sizeof (buf), STRFTIME_YEAR_MODIFIER "-%m-%dT%TZ", &tm); else if (prop_type == TRACKER_PROPERTY_TYPE_DATE) - retval = strftime ((gchar *) &buf, sizeof (buf), "%2C%y-%m-%d", &tm); + retval = strftime ((gchar *) &buf, sizeof (buf), STRFTIME_YEAR_MODIFIER "-%m-%d", &tm); else g_assert_not_reached (); -- cgit v1.2.1