aureliendavid / rsspreview

WebExtension to preview RSS feeds in the browser
MIT License
99 stars 6 forks source link

Datetimes should be formatted as human-readable #8

Closed matthewkogan closed 5 years ago

matthewkogan commented 5 years ago

2018-12-12T11:14:16.653Z should appear as 12 December 2018, 11:14 or similar.

IoApo commented 5 years ago

hi there! This feature has to take into account the different timezones as well, as noone has the same time. This could also help in conjuction/relation to the possibility for translating feeds [ #6 ] so the date format would be in a more human-readable way, and with localization as well (non mandatory though).

Timing with a reference to the timezone could help, especially if the feed provides correctly the date-time info.

aureliendavid commented 5 years ago

hi

I think the browser can do all this for us with stuff like toLocaleDateString in conjunction with navigator.language but I haven't had time to look into it properly

for now I just copy the dates as raw strings taken in the feed source which is sufficient for me

I'll try to do it soon

johnhawkinson commented 5 years ago

Hi! FF63 refugee here. RSSPreview does a great job of restoring the functionality that just disappeared with an FF64 upgrade, but I tended to make significant use of the timing information in RSS feed previews and doing timezone math (whether in my head or by copy/pasting) is not a great experience.


Here's a comparison, using https://ecf.mad.uscourts.gov/cgi-bin/rss_outside.pl:

screen shot 2018-12-14 at 05 18 18 screen shot 2018-12-14 at 05 39 17

I think the browser can do all this for us with stuff like toLocaleDateString in conjunction with navigator.language but I haven't had time to look into it properly

Yes. You can get 90% of the way there without navigator.language:

>> (new Date).toLocaleString()
"12/14/2018, 6:02:07 AM"

And nearly there (And probably better!) with toLocaleDateString():

>> d=new Date
Date 2018-12-14T11:00:19.826Z
>> var options = {  year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric'};
undefined
>> d.toLocaleDateString(navigator.language, options)
"December 14, 2018, 6:00:19 AM"
>> var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric'};
undefined
>> d.toLocaleDateString(navigator.language, options)
"Friday, December 14, 2018, 6:00:19 AM"

But to make it look exactly as it did in FF63, with the " at " in the middle, you need to separately convert the date and time and concatenate them with [the localization of?] "at". It's a shame that Date.prototype.toLocaleFormat() is deprecated (the JS strftime() equivalent). But I think my preference would be to just use what's achievable with toLocaleDateString()

aureliendavid commented 5 years ago

I did it in the commit mentioned above (I think I like it better with the day-of-week and without the 'at').

I'll publish an update to AMO a bit later.

thanks for the feedback

aureliendavid commented 5 years ago

I've updated it on AMO (v2.2).

Reopen this issue if there are still problems on this subject.

thanks