quazeryon
Active member
- Joined
- Apr 13, 2020
- Messages
- 1
- Points
- 43
Currently the time handling of the site is rather basic.
- There aren't any daylight savings adjustments aside of manually switching timezones.
- It is hard to figure out at which time newly released chapters actually got released. (e.g. a chapter was released 12 hours ago, but an hour long window still remains)
- The date is always in an english/american format, which is also rather hard to to parse.
However, if there was a unix-timestamp delivered with each date (e.g. as property or data-timestamp attribute) Javascript could easily generate localized values with the Date::toLocaleString() method and Date::toLocaleDateString() method.
While it would obviously nice, if the site itself could handle such adjustments, just offering the timestamp would also be enough, since userscripts can take care of the rest.
E.g.:
- There aren't any daylight savings adjustments aside of manually switching timezones.
- It is hard to figure out at which time newly released chapters actually got released. (e.g. a chapter was released 12 hours ago, but an hour long window still remains)
- The date is always in an english/american format, which is also rather hard to to parse.
However, if there was a unix-timestamp delivered with each date (e.g. as property or data-timestamp attribute) Javascript could easily generate localized values with the Date::toLocaleString() method and Date::toLocaleDateString() method.
While it would obviously nice, if the site itself could handle such adjustments, just offering the timestamp would also be enough, since userscripts can take care of the rest.
E.g.:
JavaScript:
// this code assumes that the tags surrounding dates have the "fic_date_pub"-class and "data-timestamp"-attribute
// also this code isn't optimized; just a quick proof of concept
let now = Date.now();
let DAY = 24 * 60 * 60 * 1000;
[...document.getElementsByClass('fic_date_pub')].forEach(e => {
e.title = new Date(e.dataset.timestamp).toLocaleString();
// to fix the hover text
// keep the current default text if the chapter got posted in the last day
// since the hovertext got updated we can get more details if we want them though that
if(now > e.dataset.timestamp + DAY)
e.textContent = new Date(e.dataset.timestamp).toLocaleDateString();
// to localize the default text
});