Commit fa81d58a authored by Sebastian Keller's avatar Sebastian Keller
Browse files

file: Only determine the local timezone once when generating date string

We can re-use the local time zone that was created for the the
file_date_time for all following date times that also use the local time
zone. This also helps with the glib time zone performance regression
by reducing the time zones created for each file from four to one.

Related: GNOME/glib#2204
GNOME/nautilus!601
parent 50371b95
Pipeline #215781 passed with stage
in 8 minutes and 23 seconds
......@@ -5520,16 +5520,18 @@ nautilus_file_get_date_as_string (NautilusFile *file,
{
GDateTime *file_date;
now = g_date_time_new_now_local ();
today_midnight = g_date_time_new_local (g_date_time_get_year (now),
g_date_time_get_month (now),
g_date_time_get_day_of_month (now),
0, 0, 0);
file_date = g_date_time_new_local (g_date_time_get_year (file_date_time),
g_date_time_get_month (file_date_time),
g_date_time_get_day_of_month (file_date_time),
0, 0, 0);
now = g_date_time_new_now (g_date_time_get_timezone (file_date_time));
today_midnight = g_date_time_new (g_date_time_get_timezone (file_date_time),
g_date_time_get_year (now),
g_date_time_get_month (now),
g_date_time_get_day_of_month (now),
0, 0, 0);
file_date = g_date_time_new (g_date_time_get_timezone (file_date_time),
g_date_time_get_year (file_date_time),
g_date_time_get_month (file_date_time),
g_date_time_get_day_of_month (file_date_time),
0, 0, 0);
days_ago = g_date_time_difference (today_midnight, file_date) / G_TIME_SPAN_DAY;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment