diff options
author | rbuj <[email protected]> | 2019-04-30 13:12:04 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2019-05-04 19:23:16 +0200 |
commit | 476f56a25be636970b336d525a7766b6d1eb3fff (patch) | |
tree | 44ee464da369bcd56331fe8b1f5e5aa64c535f94 /libcaja-private | |
parent | 02646f7773b7b9b46df570e06084e428817889f0 (diff) | |
download | caja-476f56a25be636970b336d525a7766b6d1eb3fff.tar.bz2 caja-476f56a25be636970b336d525a7766b6d1eb3fff.tar.xz |
eel: remove date & time functions
Do not need to extend glib library, since it now incorporates these functions.
Extended date format modifiers are available on glib v2.56.
eel-glib-extensions.h/c:
GDate * eel_g_date_new_tm (struct tm *time_pieces);
char * eel_strdup_strftime (const char *format, struct tm *time_pieces);
gint64 eel_get_system_time (void);
Do not need to test the extensions in eel_self_check_glib_extensions (void).
eel-glib-extensions.c:
static void check_tm_to_g_date (time_t time)
static char * test_strftime (...)
Do not need to check if strftime implements extended date format modifiers on the system (available on glibc v2.27).
configure.ac
Diffstat (limited to 'libcaja-private')
-rw-r--r-- | libcaja-private/caja-dnd.c | 2 | ||||
-rw-r--r-- | libcaja-private/caja-file.c | 48 | ||||
-rw-r--r-- | libcaja-private/caja-icon-container.c | 4 | ||||
-rw-r--r-- | libcaja-private/caja-icon-dnd.c | 2 |
4 files changed, 27 insertions, 29 deletions
diff --git a/libcaja-private/caja-dnd.c b/libcaja-private/caja-dnd.c index 584af6ed..83ae648e 100644 --- a/libcaja-private/caja-dnd.c +++ b/libcaja-private/caja-dnd.c @@ -1006,7 +1006,7 @@ caja_drag_autoscroll_start (CajaDragInfo *drag_info, if (drag_info->auto_scroll_timeout_id == 0) { drag_info->waiting_to_autoscroll = TRUE; - drag_info->start_auto_scroll_in = eel_get_system_time() + drag_info->start_auto_scroll_in = g_get_monotonic_time() + AUTOSCROLL_INITIAL_DELAY; drag_info->auto_scroll_timeout_id = g_timeout_add diff --git a/libcaja-private/caja-file.c b/libcaja-private/caja-file.c index 9a7d8719..3be71387 100644 --- a/libcaja-private/caja-file.c +++ b/libcaja-private/caja-file.c @@ -4806,40 +4806,32 @@ caja_file_fit_date_as_string (CajaFile *file, void *measure_context) { time_t file_time_raw; - struct tm *file_time; const char **formats; const char *width_template; const char *format; char *date_string; - char *result; - GDate *today; - GDate *file_date; - guint32 file_date_age; + gchar *result = NULL; int i; + GDateTime *date_time, *today; + GTimeSpan file_date_age; if (!caja_file_get_date (file, date_type, &file_time_raw)) { return NULL; } - file_time = localtime (&file_time_raw); + date_time = g_date_time_new_from_unix_local (file_time_raw); if (date_format_pref == CAJA_DATE_FORMAT_LOCALE) { - return eel_strdup_strftime ("%c", file_time); + result = g_date_time_format (date_time, "%c"); + goto out; } else if (date_format_pref == CAJA_DATE_FORMAT_ISO) { - return eel_strdup_strftime ("%Y-%m-%d %H:%M:%S", file_time); + result = g_date_time_format (date_time, "%Y-%m-%d %H:%M:%S"); + goto out; } - file_date = eel_g_date_new_tm (file_time); - - today = g_date_new (); - g_date_set_time_t (today, time (NULL)); - - /* Overflow results in a large number; fine for our purposes. */ - file_date_age = (g_date_get_julian (today) - - g_date_get_julian (file_date)); - - g_date_free (file_date); - g_date_free (today); + today = g_date_time_new_now_local (); + file_date_age = g_date_time_difference (today, date_time); + g_date_time_unref (today); /* Format varies depending on how old the date is. This minimizes * the length (and thus clutter & complication) of typical dates @@ -4849,9 +4841,9 @@ caja_file_fit_date_as_string (CajaFile *file, * internationalization's sake. */ - if (file_date_age == 0) { + if (file_date_age < G_TIME_SPAN_DAY) { formats = TODAY_TIME_FORMATS; - } else if (file_date_age == 1) { + } else if (file_date_age < 2 * G_TIME_SPAN_DAY) { formats = YESTERDAY_TIME_FORMATS; } else { formats = CURRENT_WEEK_TIME_FORMATS; @@ -4874,15 +4866,16 @@ caja_file_fit_date_as_string (CajaFile *file, * shortest format */ - date_string = eel_strdup_strftime (format, file_time); + date_string = g_date_time_format (date_time, format); if (truncate_callback == NULL) { - return date_string; + result = date_string; + break; } result = (* truncate_callback) (date_string, width, measure_context); g_free (date_string); - return result; + break; } format = _(formats [i + 1]); @@ -4898,8 +4891,13 @@ caja_file_fit_date_as_string (CajaFile *file, } } - return eel_strdup_strftime (format, file_time); + if (result == NULL) { + result = g_date_time_format (date_time, format); + } +out: + g_date_time_unref (date_time); + return result; } /** diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 1d24eba0..ac78e451 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -4797,7 +4797,7 @@ caja_icon_container_did_not_drag (CajaIconContainer *container, g_object_get (G_OBJECT (gtk_widget_get_settings (GTK_WIDGET (container))), "gtk-double-click-time", &double_click_time, NULL); - current_time = eel_get_system_time (); + current_time = g_get_monotonic_time (); if (current_time - last_click_time < double_click_time * 1000) { click_count++; @@ -4852,7 +4852,7 @@ clicked_within_double_click_interval (CajaIconContainer *container) g_object_get (G_OBJECT (gtk_widget_get_settings (GTK_WIDGET (container))), "gtk-double-click-time", &double_click_time, NULL); - current_time = eel_get_system_time (); + current_time = g_get_monotonic_time (); if (current_time - last_click_time < double_click_time * 1000) { click_count++; diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c index 7c03cd2b..40f57cc1 100644 --- a/libcaja-private/caja-icon-dnd.c +++ b/libcaja-private/caja-icon-dnd.c @@ -855,7 +855,7 @@ auto_scroll_timeout_callback (gpointer data) container = CAJA_ICON_CONTAINER (widget); if (container->details->dnd_info->drag_info.waiting_to_autoscroll - && container->details->dnd_info->drag_info.start_auto_scroll_in > eel_get_system_time()) + && container->details->dnd_info->drag_info.start_auto_scroll_in > g_get_monotonic_time()) { /* not yet */ return TRUE; |