mirror of https://github.com/espruino/BangleApps
Fix date_utils if timezone is 12.
https://forum.espruino.com/conversations/387709/#comment17024817pull/2834/head
parent
b0ccc6c678
commit
5ae91b90b0
|
@ -22,7 +22,7 @@
|
|||
* @returns The localized name of the i-th day of the week
|
||||
*/
|
||||
exports.dow = (i, abbreviated) => {
|
||||
var dow = require("locale").dow(new Date(((i || 0) + 3.5) * 86400000), abbreviated).slice(0, (abbreviated == 2) ? 1 : 100);
|
||||
var dow = require("locale").dow({getDay:()=>(i|0)%7}, abbreviated).slice(0, (abbreviated == 2) ? 1 : 100);
|
||||
return abbreviated == 2 ? dow.toUpperCase() : dow;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ exports.dows = (firstDayOfWeek, abbreviated) => {
|
|||
* @returns The localized name of the i-th month
|
||||
*/
|
||||
exports.month = (i, abbreviated) => {
|
||||
var month = require("locale").month(new Date((i - 0.5) * 2628000000), abbreviated).slice(0, (abbreviated == 2) ? 1 : 100);
|
||||
var month = require("locale").month({getMonth:()=>(11+(i|0))%12}, abbreviated).slice(0, (abbreviated == 2) ? 1 : 100);
|
||||
return abbreviated == 2 ? month.toUpperCase() : month;
|
||||
}
|
||||
|
||||
|
@ -58,8 +58,7 @@ exports.month = (i, abbreviated) => {
|
|||
exports.months = (abbreviated) => {
|
||||
var months = [];
|
||||
var locale = require("locale");
|
||||
for (var i = 1; i <= 12; i++) {
|
||||
months.push(locale.month(new Date((i - 0.5) * 2628000000), abbreviated).slice(0, (abbreviated == 2) ? 1 : 100));
|
||||
}
|
||||
for (var i = 0; i < 12; i++)
|
||||
months.push(locale.month({getMonth:()=>i}, abbreviated).slice(0, (abbreviated == 2) ? 1 : 100));
|
||||
return abbreviated == 2 ? months.map(month => month.toUpperCase()) : months;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue