Skip to content

Commit 173e6d2

Browse files
authored
Merge pull request #735 from atjn/internationalisation-meridians
Document use of meridian
2 parents 9037679 + b20bf5c commit 173e6d2

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

tutorials/Bangle.js Locale.md

+26-6
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ How do you use it?
2525

2626
Simply call `require("locale")` in your code and use the provided object.
2727

28-
For instance, if you want to write a date in a locale-friendly way, just use:
28+
For instance, if you want to show the clock in a locale-friendly way, just use:
2929

3030
```JS
31-
var myDate = new Date();
32-
var dateString = require("locale").date(myDate);
31+
let myDate = new Date();
32+
let clockString = require("locale").time(myDate) + " " + require("locale").meridian(myDate);
33+
g.drawString(clockString);
34+
```
35+
36+
And for a locale-friendly date:
37+
38+
```JS
39+
let myDate = new Date();
40+
let dateString = require("locale").date(myDate);
3341
g.drawString(dateString);
3442
```
3543

@@ -94,15 +102,27 @@ correctly in the console. They may need to be rendered with
94102

95103
// Date to time string (long)
96104
>require("locale").time(new Date())
97-
="15:49:39"
105+
="03:49:39" // If user chose 12-hour clock
106+
="15:49:39" // If user chose 24-hour clock
98107

99108
// Date to time string (short)
100109
>require("locale").time(new Date(), 1)
101-
="15:49"
110+
="03:49" // If user chose 12-hour clock
111+
="15:49" // If user chose 24-hour clock
102112

103113
// Date to meridian (text describing morning/evening)
104114
>require("locale").meridian(new Date())
105-
="" // or "pm" for en_GB
115+
="PM" // If user chose 12-hour clock
116+
="" // If user chose 24-hour clock
117+
118+
// Date to meridian (forced)
119+
>require("locale").meridian(new Date(), true)
120+
="PM" // No matter which hour format is used
121+
122+
// Check which hour format the watch uses
123+
>require("locale").is12Hours()
124+
=true // If user chose 12-hour clock
125+
=false // If user chose 24-hour clock
106126
```
107127

108128
`date_utils` module

0 commit comments

Comments
 (0)