standardnotes / desktop

[Moved to https://github.com/standardnotes/app] A free, open-source, and end-to-end encrypted notes app. https://standardnotes.com
GNU Affero General Public License v3.0
1.4k stars 115 forks source link

Use system settings for date formatting #332

Closed hl2guide closed 3 years ago

hl2guide commented 5 years ago

I live in Australia and have Windows 10 set to the Australian language pack installed and active. The timestamps for notes in Standard Notes appear as "16:30" instead of the expected (localized) time of "4:30PM".

Does Standard Notes fully support 12 hour time formats?

moughxyz commented 5 years ago

We do use locale settings for dates: https://github.com/standardfile/sfjs/blob/master/lib/app/models/item.js#L435

Perhaps try running this snippet in your browser developer console and see what result you get. You can also open the JS inspector in the desktop app using Help > Toggle Error Console.

hl2guide commented 5 years ago

I tried running that snippet within a browser and within Standard Notes Error Console.

Both resulted in: SyntaxError: export declarations may only appear at top level of a module debugger eval code:3 Uncaught SyntaxError: Unexpected token export

I also saw: C:\Users\Dean\AppData\Local\Programs\standard-notes\resources\app.asar\dist\javascripts\render\spellcheck.js:71 Using OS-level spell check API with locale en_GB

moughxyz commented 5 years ago

Well, not sure what snippet you ran directly, but you'd have to modify it a bit to work without context:

var locale = (navigator.languages && navigator.languages.length) ? navigator.languages[0] : navigator.language;
let dateFormatter = new Intl.DateTimeFormat(locale, {
  year: 'numeric',
  month: 'short',
  day: '2-digit',
  weekday: 'long',
  hour: '2-digit',
  minute: '2-digit',
});
console.log(dateFormatter.format(new Date()));
hl2guide commented 5 years ago

ah ok, my bad. That snippet resulted in the below.

Standard Notes:

Thursday, 18 Apr 2019, 00:25 undefined

Firefox:

Thursday, 18 Apr 2019, 12:24 am debugger eval code:10:1 undefined

moughxyz commented 5 years ago

Hmm..do you have Chrome installed? Curious to see what it would report. The desktop app is based on Electron is based on Chromium, so that would get us the highest correlation.

hl2guide commented 5 years ago

I ran it in Opera (uses Chromium/Blink engine to my knowledge): Thursday, 18 Apr 2019, 00:34 undefined

moughxyz commented 5 years ago

So yeah, something with that browser engine is yielding 24 hour time. Not quite sure what this is. My hunch is that there's a system preference somewhere that controls this.

hl2guide commented 5 years ago

Maybe Standard Notes could have a "use 12 hour time format" boolean flag that acts as an override?

moughxyz commented 5 years ago

Yeah, maybe. We generally don't have a preferences pane yet to place things like these. But if and when we do, this option would definitely make a good candidate.

leafcutterant commented 5 years ago

I'd add my experience with this: I use a US locale, but changed the system settings to display a 24-hour format. Standard Notes still goes with AM/PM, so I suspect it pulls the system locale and decides based on that, not on the system preference. It would be better if it could follow the preference.

kmantel commented 3 years ago

This problem is still present - standardnotes must be following the locale's default like leafcutterant says, even if the time settings are changed. It would be great if standardnotes could follow the time setting rather than the locale or allow an override in app.

JaspalSuri commented 3 years ago

Thanks for the feedback on that! We'll consider it when building out a preference for customizing the formatting of timestamps used in the notes list (and elsewhere). 🙂