[frogr] Remove deprecated use of GTimeVal



commit 89d5c0b03ece036915cd826426aa9cd7c5a85eaa
Author: Mario Sanchez Prada <msanchez gnome org>
Date:   Thu Jan 9 01:11:06 2020 +0100

    Remove deprecated use of GTimeVal
    
    GTimeVal has been deprecated since version 2.62 due to not being
    year-2038-safe, so let's migrate away from it now.

 src/frogr-controller.c | 18 ++----------------
 src/frogr-photoset.c   | 13 +++++++------
 2 files changed, 9 insertions(+), 22 deletions(-)
---
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index 43aa0e0..1084468 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -1308,8 +1308,7 @@ static void
 _set_replace_date_posted_for_picture (FrogrController *self, UploadOnePictureData *uop_data)
 {
   FrogrPicture *picture = NULL;
-  GDateTime *picture_date = NULL;
-  GTimeVal picture_timeval;
+  g_autoptr(GDateTime) picture_date = NULL;
   const gchar *picture_date_str = NULL;
   g_autofree gchar *debug_msg = NULL;
   gchar date_iso8601[20];
@@ -1329,18 +1328,7 @@ _set_replace_date_posted_for_picture (FrogrController *self, UploadOnePictureDat
   date_iso8601[7] = '-';
   date_iso8601[19] = '\0';
 
-  if (!g_time_val_from_iso8601 (date_iso8601, &picture_timeval))
-    return;
-
-  /* It's not correct to just do this because the date extracted from the EXIF information might
-     not have been stored in UTC. However, it seems there's no a much better solution since many
-     cameras don't use the TimeZoneOffset EXIF tag, so we can't rely on that either. And even if
-     it exists, I could not find any picture with that field in the EXIF information so I guess
-     that, all in all, using the 'date taken' as 'posted' as if it was UTC (regardless of whether
-     it's actually UTC) is probably fine anyway. After all, it's not supposed to be shown in
-     flickr and would serve most of the times just to have the photostream sorted by 'date
-     taken', and for that, using the date as UTC would be good enough .*/
-  picture_date = g_date_time_new_from_timeval_utc (&picture_timeval);
+  picture_date = g_date_time_new_from_iso8601 (date_iso8601, g_time_zone_new_utc ());
   if (!picture_date)
     return;
 
@@ -1356,8 +1344,6 @@ _set_replace_date_posted_for_picture (FrogrController *self, UploadOnePictureDat
   debug_msg = g_strdup_printf ("Replacing 'date posted' with 'date taken' (%s) for picture %s…",
                                date_iso8601, frogr_picture_get_title (picture));
   DEBUG ("%s", debug_msg);
-
-  g_date_time_unref (picture_date);
 }
 
 static gboolean
diff --git a/src/frogr-photoset.c b/src/frogr-photoset.c
index 1ece487..2d737a7 100644
--- a/src/frogr-photoset.c
+++ b/src/frogr-photoset.c
@@ -67,14 +67,15 @@ _create_temporary_id_for_photoset (void)
      "good enough" */
   static guint serial = 0;
   gchar* key;
-  guint t, ut, p, u;
+  gint64 tv, t, ut;
+  pid_t p;
+  uid_t u;
   guint32 r;
-  GTimeVal tv;
 
-  g_get_current_time(&tv);
+  tv = g_get_real_time ();
 
-  t = tv.tv_sec;
-  ut = tv.tv_usec;
+  t = tv / G_USEC_PER_SEC;
+  ut = tv;
 
   p = getpid();
   u = getuid();
@@ -87,7 +88,7 @@ _create_temporary_id_for_photoset (void)
 
   /* The letters may increase uniqueness by preventing "melds"
      i.e. 01t01k01 and 0101t0k1 are not the same */
-  key = g_strdup_printf("%ut%uut%uu%up%ur%uk%u",
+  key = g_strdup_printf("%ut%liut%liu%up%ir%uk%u",
                         /* Duplicate keys must be generated
                            by two different program instances */
                         serial,


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