Feature #5081
Time stamp format is not respecting system locale nor language settings
0%
Description
Hi!
The timestamp format in listed recordings is wd M/D/YYYY h:mm:ss. This is backwards to what I want and is very counterintuitive, and contradicts both my system locale and language settings in tvheadend! The program should be less US-sentric.
Moreover, short weekday (wd) is translated according to the language setting but the rest (time stamp format) is not.
Curiously, in EPG window, the time format is different (possibly because year is not relevant information). Here it is "Wd, Month DD, HH:MM". Month is a truncated finnish month name. This format does not conform to any finnish date format and is very awkward, but at least is easier to understand since I do not need to guess which number is date and which is month (since there is only one :-) ! )
Suggestion: Time stamps should be shown according to system locale or the language setting in tvheadend. As a lower priority, there should be more control over this; for example, does the user want to see the weekday at all or will jsut the date suffice, is a matter of taste. OTOH, it might bve easier to give the user the option to define the timestamps rather than using system locale. I have no idea what kind of libraries / utilities exist which could spit out timestamp specs according to the locale and/or language (I presume this is a common need and there must be some solutions out there).
Another issue is that the default fields in the WEeb UI are 99% of the time too small and do not show relevent information (time of day, but only some of the date). User needs to adjust the width of these fields constantly.
History
Updated by Pablo Zerón over 6 years ago
Hi,
You can use the sytem locale time format if you change the function "renderDate" in the "epg.js" file by this:
function renderDate(value, meta, record) {
setMetaAttr(meta, record);
if (value) {
var dt = new Date(value);
var options = { weekday: 'short', month: 'short', day: 'numeric', hour:'2-digit', minute: '2-digit'};
return dt.toLocaleDateString(navigator.language, options);
//return dt.format('D, M d, H:i'); // Previous format, you can delete it.
}
return "";
}
About timestamp in the recordings, I think you can get a better answer from @perexg.
Updated by Jaroslav Kysela over 6 years ago
The grids use standard Date().toLocaleString() - see idnode.js . It means that browser's locale is used instead tvheadend's locale. All date values are in UTC, so the locale conversion is proceed in the javascript.
Pablo, is the options seems somewhat undocumented, only MSN contains info about this.. Is this a standard?
Anyway, I don't mind about this. If you tune this, just send me a PR to review.
Updated by Pablo Zerón over 6 years ago
The Date().toLocaleDataString() use the Intl.DateTimeFormat object included in the ECMA-402 Edition 1.0, and the options are defined there.
Ok, I will take a look.
Updated by Wild Penguin over 6 years ago
Jaroslav Kysela wrote:
The grids use standard Date().toLocaleString() - see idnode.js . It means that browser's locale is used instead tvheadend's locale. All date values are in UTC, so the locale conversion is proceed in the javascript.
Pablo, is the options seems somewhat undocumented, only MSN contains info about this.. Is this a standard?
Anyway, I don't mind about this. If you tune this, just send me a PR to review.
Does this mean that the browsers language setting should be respected? Does it work for you?
I'm using Firefox (59.0.2 currently) and my preferred languages (in Preferences -> General -> Language -> Choose) are: [fi-fi]; Finnish [fi]; English/United Kingdom [en-gb]; English/United States [en-us]; English [en]; German/Germany [de-de]. No idea why Finnish is listed twice ...
I have no language pack installed, I'll see if that makes any difference.
Updated by Wild Penguin over 6 years ago
Wild Penguin wrote:
I have no language pack installed, I'll see if that makes any difference.
Ok, a workaround (wlthough partial) is installing a (finnish/[insert your language here]) language pack made the timestamps in the webui in the finished (or failed) recording listing conform to finnish (i.e. "wd d.m.yyyy klo h.m.s"). I was a bit surprised about this, but if someone else is bothered about this: try to change the browser language (not just web page preferred rendered language setting)!
The EPG view is still a bit weird; currently it is still "Wd, Month DD, HH:MM"; according to finnish locale this is almost correct but dd<->month should be reversed, i.e. "Wd, dd month, hh:mm" would be technically correct. But for my brain using short monthnames is always a bit awkward in finnish, while being officially correct and accepted. This is the reason why they are rarely used; it is either long month names (if there is loads of space) or jusing numbers. I.e. "Wd d.m. hh:mm" would be shorted and more readable (and possibly even omitting wd, since to me it just seems superfluos; OTOH if the user doesn't remember the current date precisely, the weekday name might be usefull).
Updated by Pablo Zerón over 6 years ago
I'm working on a webui PR to use the user language selected in the user tab, so the dates will showed in the right format.
After take a look to the code, the timestamp used in the file recordings use the function 'strftime()' [[http://www.cplusplus.com/reference/ctime/strftime/]], so if you system locale are configured correctly, you can use '%x' or '%d-%m-%Y' in 'Format string/Pathname specification' to get a right filename.
Updated by Pablo Zerón over 6 years ago
After this, I will try to implement a custom date format as a new config option.