Desktop: Use system settings for date formatting

Created on 17 Apr 2019  路  10Comments  路  Source: standardnotes/desktop

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?

enhancement

Most helpful comment

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.

All 10 comments

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.

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\resourcesapp.asar\dist\javascripts\render\spellcheck.js:71 Using OS-level spell check API with locale en_GB

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()));

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

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.

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

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.

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

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.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xioren picture xioren  路  5Comments

Eduardo06sp picture Eduardo06sp  路  5Comments

chanclr picture chanclr  路  5Comments

mem101296 picture mem101296  路  5Comments

derkommandant picture derkommandant  路  5Comments