-
Notifications
You must be signed in to change notification settings - Fork 870
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
respect region time format on NTP #3256
Conversation
I don't see that this respects 24-hour clock in macOS @cezaraugusto how did you get the test plan to pass in macOS? Either way, I think it's better than current Edit: I don't think there's a way to get the system 24-hour / 12-hour preference. Instead I think we should mark that this PR solves the issue of the incorrect 0 prefix, and keep the 24-hour / 12-hour issue as unsolved untile we make a preference (perhaps double-clicking the clock switches between 24-hour / 12-hour like in the Momentum extension NTP). |
return new Intl.DateTimeFormat([], { hour: '2-digit', minute: '2-digit' }) | ||
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat | ||
const options = { hour: 'numeric', minute: 'numeric' } | ||
return new Intl.DateTimeFormat([], options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that this fixes the issue, but according to the linked documentation, the first parameter should be undefined
, right?
A string with a BCP 47 language tag, or an array of such strings. To use the browser's default locale, omit this argument or pass undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, but I think the algorithm ignores it anyway. I just left it with what we had
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
@petemill this fix does solve the issue as stated by OP In fact, the above was my test plan, but to avoid asking reviewers to change their system to an unknown language, I changed the test plan for just the time format, which doesn't work to my surprise. In my opinion, if the Web API integration with the system is limited, then there's nothing we can do, and instead of marking the issue as fixed we should mark it as worth noting that I also tried using const event = new Date(Date.now())
event.toLocaleDateString(undefined, {timeStyle: 'short'}) I'm going to update both the issue and this PR test plan to reflect the above. |
18f97ab
to
8bc3889
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice update to the issue and test plan. Let's see why Jenkins is complaining before merging
Just needs rebasing @cezaraugusto |
fix brave/brave-browser#1308 this change allows users with 24-hour format to see time on NTP the same way their system defined. defaults to whichever locale user defined on their system settings.
rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested out, LGTM; comments made in brave/brave-browser#1308 (comment) definitely make sense 👍
fix brave/brave-browser#1308
this change allows users with 24-hour format to see time on NTP the same way their system defined. defaults to whichever locale user defined on their system settings.
Test Plan:
Reviewer Checklist:
After-merge Checklist:
changes has landed on.