+void init_exif_time_data(GList *files)
+{
+ FileData *file;
+ DEBUG_1("%s init_exif_time_data: ...", get_exec_time());
+ while (files)
+ {
+ file = files->data;
+
+ if (file)
+ file->exifdate = 0;
+
+ files = files->next;
+ }
+}
+
+void read_exif_time_data(FileData *file)
+{
+ if (file->exifdate > 0)
+ {
+ DEBUG_1("%s set_exif_time_data: Already exists for %s", get_exec_time(), file->path);
+ return;
+ }
+
+ file->exif = exif_read_fd(file);
+
+ if (file->exif)
+ {
+ gchar *tmp = exif_get_data_as_text(file->exif, "Exif.Photo.DateTimeOriginal");
+ DEBUG_2("%s set_exif_time_data: reading %p %s", get_exec_time(), file, file->path);
+
+ if (tmp)
+ {
+ struct tm time_str;
+ uint year, month, day, hour, min, sec;
+
+ sscanf(tmp, "%4d:%2d:%2d %2d:%2d:%2d", &year, &month, &day, &hour, &min, &sec);
+ time_str.tm_year = year - 1900;
+ time_str.tm_mon = month - 1;
+ time_str.tm_mday = day;
+ time_str.tm_hour = hour;
+ time_str.tm_min = min;
+ time_str.tm_sec = sec;
+ time_str.tm_isdst = 0;
+
+ file->exifdate = mktime(&time_str);
+ g_free(tmp);
+ }
+ }
+}
+
+void set_exif_time_data(GList *files)
+{
+ DEBUG_1("%s set_exif_time_data: ...", get_exec_time());
+
+ while (files)
+ {
+ FileData *file = files->data;
+
+ read_exif_time_data(file);
+ files = files->next;
+ }
+}
+