[tracker/wip/carlosg/datetime-fixes: 4/5] libtracker-common: Ensure to print at least 4 year digits




commit 4e28ffbc89597ad9367a997ab52790ca1786b0af
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Oct 10 13:59:08 2020 +0200

    libtracker-common: Ensure to print at least 4 year digits
    
    Expand the %F in strftime() to %4Y-%M-%D, otherwise for years < 1000
    we end up eating digits, and producing a not quite ISO8601 string.
    
    Fixes: https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/146

 src/libtracker-common/tracker-date-time.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/src/libtracker-common/tracker-date-time.c b/src/libtracker-common/tracker-date-time.c
index 03ee078d5..003239f6a 100644
--- a/src/libtracker-common/tracker-date-time.c
+++ b/src/libtracker-common/tracker-date-time.c
@@ -222,7 +222,7 @@ tracker_date_to_string (gdouble date_time,
        gmtime_r (&seconds, &utc_time);
 
        /* Output is ISO 8601 format : "YYYY-MM-DDThh:mm:ss" */
-       count = strftime (buffer, sizeof (buffer), "%FT%T", &utc_time);
+       count = strftime (buffer, sizeof (buffer), "%4Y-%m-%dT%T", &utc_time);
 
        /* Append milliseconds (if non-zero) and time zone */
        if (milliseconds > 0) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]