summaryrefslogtreecommitdiff
path: root/libcaja-private
diff options
context:
space:
mode:
authorStefan Pöschel <[email protected]>2023-04-15 12:42:37 +0200
committerraveit65 <[email protected]>2023-10-12 12:43:28 +0200
commitff7a9042077966964d898ffb66e7846bab8fec89 (patch)
treea21a90da285064f9b4ad5bb082fe4dac1772f352 /libcaja-private
parentaa80005f4f2f0fe3cfbc2517213167397c1a1ce0 (diff)
downloadcaja-ff7a9042077966964d898ffb66e7846bab8fec89.tar.bz2
caja-ff7a9042077966964d898ffb66e7846bab8fec89.tar.xz
caja-file: fix yesterday/today informal date bug
If informal date format is used, the yesterday/today ranges of 48/24 hours apply to the end of the current day, not to the current instant. Fixes a regression introduced by 476f56a25be636970b336d525a7766b6d1eb3fff. Fixes #1621.
Diffstat (limited to 'libcaja-private')
-rw-r--r--libcaja-private/caja-file.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libcaja-private/caja-file.c b/libcaja-private/caja-file.c
index 4d4a40d4..32c3e650 100644
--- a/libcaja-private/caja-file.c
+++ b/libcaja-private/caja-file.c
@@ -4862,7 +4862,7 @@ caja_file_fit_date_as_string (CajaFile *file,
char *date_string;
gchar *result = NULL;
int i;
- GDateTime *date_time, *today;
+ GDateTime *date_time, *today, *end_of_today;
GTimeSpan file_date_age;
if (!caja_file_get_date (file, date_type, &file_time_raw)) {
@@ -4880,9 +4880,15 @@ caja_file_fit_date_as_string (CajaFile *file,
}
today = g_date_time_new_now_local ();
- file_date_age = g_date_time_difference (today, date_time);
+ end_of_today = g_date_time_add_full (today, 0, 0, 1,
+ -1 * g_date_time_get_hour (today),
+ -1 * g_date_time_get_minute (today),
+ -1.0 * g_date_time_get_seconds (today));
g_date_time_unref (today);
+ file_date_age = g_date_time_difference (end_of_today, date_time);
+ g_date_time_unref (end_of_today);
+
/* Format varies depending on how old the date is. This minimizes
* the length (and thus clutter & complication) of typical dates
* while providing sufficient detail for recent dates to make