Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date format #1

Open
piotro21 opened this issue Jan 10, 2022 · 1 comment
Open

date format #1

piotro21 opened this issue Jan 10, 2022 · 1 comment

Comments

@piotro21
Copy link

Hi, could you consider other date/time formats? My system, and firefox for that matter, use the ISO YYYY-MM-DD format, but the Tooltip displays DD.MM.YYYY instead.
Many thanks for the extension 👍

@rotemdan
Copy link
Owner

rotemdan commented Jan 10, 2022

The code uses toLocaleDateString and toLocaleTimeString to format the date and time::

const originDate = new Date(originTimestamp);
return `${originDate.toLocaleDateString()} ${originDate.toLocaleTimeString()}`;

Both these functions are based on the browser's default language / locale:

The toLocaleDateString() method returns a string with a language sensitive representation of the date portion of the specified date in the user agent's timezone.

The toLocaleTimeString() method returns a string with a language-sensitive representation of the time portion of the date.

The date the extension shows in the tooltip uses a short date format for the browser's default locale. It's possible to change it to a long format, but that will be even more dependent on the current language / locale and I'm not sure it would be preferable. Here's an example of long date formatting, from MDN:

const event = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };

console.log(event.toLocaleDateString('de-DE', options));
// expected output (varies according to local timezone): Donnerstag, 20. Dezember 2012

console.log(event.toLocaleDateString('ar-EG', options));
// expected output (varies according to local timezone): الخميس، ٢٠ ديسمبر، ٢٠١٢

Anyway, it's a simple extension I wrote years ago. I'm not really interested or motivated to put the time and work to add configuration options to it (which would include a dedicated settings page, storage and synchronization code, requesting further permissions, etc.). I don't feel it would be worth the effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants