Closed Bug 1035754 Opened 8 years ago Closed 7 years ago

[Gaia][lock screen] support 24 hour time format

Categories

(Firefox OS Graveyard :: Gaia::System::Lockscreen, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(feature-b2g:2.1)

RESOLVED FIXED
2.1 S3 (29aug)
feature-b2g 2.1

People

(Reporter: howie, Assigned: gweng)

References

Details

Attachments

(1 file)

46 bytes, text/x-github-pull-request
timdream
: review+
Details | Review
There will be a setting toggle to let user choose between 12/24 hour time format in v2.1. User story and settings spec: Bug 903683

For each app, the tasks to do after toggle is added would be:
1.Read/listen to the time format toggle value/change event.

2.Input the corresponding time format to existing mozL10n.DateTimeFormat() function. Currently the input time format should be a fixed 12 hour 
shortTimeFormat = %I:%M %p , line 201 of http://goo.gl/DR4CNe. There will be a 24 hour time format added.

3.Show the return of the function as it's doing now.
To have Greg as assignee for this bug first, will post more details after setting part is done, thanks.
Assignee: nobody → gweng
Target Milestone: --- → 2.1 S3 (29aug)
Test steps:

1. Open settings app
2. change the Time format settings in Settings > Date & Time > Time Format panel

Expect:

The time format in lock screen will be changed.


here's the patch steps to apply correct time format:

1. include navigator.mozHour12 API shim in gaia app's html

```
<script defer src="shared/js/date_time_helper.js"></script>
```

(currently we still need at least `settings: readonly` permission in manifest, which might changed in next release)


2. detect proper time format via mozHour12 API, and get correct time format string from new 'shortTimeFormat12'/'shortTimeFormat24'.

```
var timeFormat = window.navigator.mozHour12 ? _('shortTimeFormat12') : _('shortTimeFormat24');
```

3. call mozL10n DateTimeFormat to localize it


4. listen to 'timeformatchange' event and localize time strings when its triggered


The full usage is at [3](WIP) for reference.


[3] https://github.com/mozilla-b2g/gaia/pull/22757/files
Attached file Patch
Patch sent, thanks!
Attachment #8472836 - Flags: review?(timdream)
Comment on attachment 8472836 [details] [review]
Patch

date_time_helper.js probably need to load before lock screen to make sure the method exist. I didn't check it.

Also, you need to rebase the patch.
Attachment #8472836 - Flags: review?(timdream) → review+
Rebased. Would land it.
master: https://github.com/mozilla-b2g/gaia/commit/6b547385b06060ebad7834eb8e90f0b00fdb8066
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.