@@ -25,11 +25,19 @@ How do you use it?
25
25
26
26
Simply call ` require("locale") ` in your code and use the provided object.
27
27
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:
29
29
30
30
``` 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);
33
41
g .drawString (dateString);
34
42
```
35
43
@@ -94,15 +102,27 @@ correctly in the console. They may need to be rendered with
94
102
95
103
// Date to time string (long)
96
104
> 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
98
107
99
108
// Date to time string (short)
100
109
> 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
102
112
103
113
// Date to meridian (text describing morning/evening)
104
114
> 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
106
126
```
107
127
108
128
` date_utils ` module
0 commit comments