Skip to content

Commit d397a94

Browse files
authored
Pad the formatted datetime (#2666)
Fixes #1538
1 parent e5e898e commit d397a94

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

libcore/FileUtils.vala

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,17 +629,28 @@ namespace Files.FileUtils {
629629

630630
switch (format) {
631631
case DateFormatMode.LOCALE:
632-
return dt.format ("%c");
632+
return emspace_pad (dt.format ("%c"));
633633
case DateFormatMode.ISO:
634-
return dt.format ("%Y-%m-%d %H:%M:%S");
634+
return emspace_pad (dt.format ("%Y-%m-%d %H:%M:%S"));
635635
case DateFormatMode.COMPACT :
636636
var locale_format_string = Posix.nl_langinfo (D_FMT);
637-
return dt.format (string.join (" ", locale_format_string.down (), "%H:%M"));
637+
var compact_format = string.join (" ", locale_format_string.down (), "%H:%M");
638+
return emspace_pad (dt.format (compact_format));
638639
default:
639-
return get_informal_date_time (dt);
640+
return emspace_pad (get_informal_date_time (dt));
640641
}
641642
}
642643

644+
// We add a fixed-width space as both prefix and suffix to ensure date is not obscured by the scrollbar (unless hovered)
645+
// regardless of the text direction
646+
// See https://github.com/elementary/files/issues/1538
647+
private string emspace_pad (string s) {
648+
var sb = new StringBuilder (s);
649+
sb.prepend_unichar (''); //Unichar emspace (U2003);
650+
sb.append_unichar (''); //Unichar emspace (U2003);
651+
return sb.str;
652+
}
653+
643654
private string get_informal_date_time (DateTime dt) {
644655
DateTime now = new DateTime.now_local ();
645656
int now_year = now.get_year ();

0 commit comments

Comments
 (0)