datevolt 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +191 -163
- package/package.json +2 -2
- package/src/duration.js +0 -188
- package/src/locale.js +0 -179
- package/src/parse.js +0 -335
- package/src/tempox.js +0 -456
package/src/duration.js
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var localeModule = require('./locale');
|
|
4
|
-
|
|
5
|
-
var MS = {
|
|
6
|
-
ms: 1, millisecond: 1, milliseconds: 1,
|
|
7
|
-
s: 1000, second: 1000, seconds: 1000,
|
|
8
|
-
m: 60000, minute: 60000, minutes: 60000,
|
|
9
|
-
h: 3600000, hour: 3600000, hours: 3600000,
|
|
10
|
-
d: 86400000, day: 86400000, days: 86400000,
|
|
11
|
-
w: 604800000, week: 604800000, weeks: 604800000,
|
|
12
|
-
M: 2629800000, month: 2629800000, months: 2629800000, // 30.4375 days
|
|
13
|
-
y: 31557600000, year: 31557600000, years: 31557600000 // 365.25 days
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// ISO 8601 duration string: P1Y2M3DT4H5M6S
|
|
17
|
-
var ISO_DURATION_REGEX = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
|
|
18
|
-
|
|
19
|
-
function Duration(input, unit) {
|
|
20
|
-
this.__isDuration = true;
|
|
21
|
-
this._locale = localeModule.getGlobalLocale();
|
|
22
|
-
|
|
23
|
-
if (typeof input === 'string') {
|
|
24
|
-
var isoMatch = input.match(ISO_DURATION_REGEX);
|
|
25
|
-
if (isoMatch) {
|
|
26
|
-
var sign = isoMatch[1] === '-' ? -1 : 1;
|
|
27
|
-
this._years = sign * parseFloat(isoMatch[2]||0);
|
|
28
|
-
this._months = sign * parseFloat(isoMatch[3]||0);
|
|
29
|
-
this._weeks = sign * parseFloat(isoMatch[4]||0);
|
|
30
|
-
this._days = sign * parseFloat(isoMatch[5]||0);
|
|
31
|
-
this._hours = sign * parseFloat(isoMatch[6]||0);
|
|
32
|
-
this._minutes = sign * parseFloat(isoMatch[7]||0);
|
|
33
|
-
this._seconds = sign * parseFloat(isoMatch[8]||0);
|
|
34
|
-
this._ms = 0;
|
|
35
|
-
this._milliseconds = 0;
|
|
36
|
-
} else {
|
|
37
|
-
this._ms = 0;
|
|
38
|
-
this._years=this._months=this._weeks=this._days=this._hours=this._minutes=this._seconds=this._milliseconds=0;
|
|
39
|
-
}
|
|
40
|
-
} else if (typeof input === 'number') {
|
|
41
|
-
var resolvedUnit = unit || 'ms';
|
|
42
|
-
var multiplier = MS[resolvedUnit] || 1;
|
|
43
|
-
this._ms = input * multiplier;
|
|
44
|
-
this._years = 0; this._months = 0; this._weeks = 0; this._days = 0;
|
|
45
|
-
this._hours = 0; this._minutes = 0; this._seconds = 0; this._milliseconds = 0;
|
|
46
|
-
this._normalizeFromMs();
|
|
47
|
-
} else if (typeof input === 'object' && input !== null) {
|
|
48
|
-
this._years = input.years || input.year || input.y || 0;
|
|
49
|
-
this._months = input.months || input.month || input.M || 0;
|
|
50
|
-
this._weeks = input.weeks || input.week || input.w || 0;
|
|
51
|
-
this._days = input.days || input.day || input.d || 0;
|
|
52
|
-
this._hours = input.hours || input.hour || input.h || 0;
|
|
53
|
-
this._minutes = input.minutes || input.minute || input.m || 0;
|
|
54
|
-
this._seconds = input.seconds || input.second || input.s || 0;
|
|
55
|
-
this._milliseconds= input.milliseconds|| input.millisecond||input.ms||0;
|
|
56
|
-
this._ms = this._toMs();
|
|
57
|
-
} else {
|
|
58
|
-
this._ms = 0;
|
|
59
|
-
this._years=this._months=this._weeks=this._days=this._hours=this._minutes=this._seconds=this._milliseconds=0;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
Duration.prototype._toMs = function() {
|
|
64
|
-
return this._years * MS.y + this._months * MS.M + this._weeks * MS.w +
|
|
65
|
-
this._days * MS.d + this._hours * MS.h + this._minutes * MS.m +
|
|
66
|
-
this._seconds * MS.s + this._milliseconds;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
Duration.prototype._normalizeFromMs = function() {
|
|
70
|
-
var remaining = Math.abs(this._ms);
|
|
71
|
-
var sign = this._ms < 0 ? -1 : 1;
|
|
72
|
-
this._years = sign * Math.floor(remaining / MS.y); remaining %= MS.y;
|
|
73
|
-
this._months = sign * Math.floor(remaining / MS.M); remaining %= MS.M;
|
|
74
|
-
this._days = sign * Math.floor(remaining / MS.d); remaining %= MS.d;
|
|
75
|
-
this._hours = sign * Math.floor(remaining / MS.h); remaining %= MS.h;
|
|
76
|
-
this._minutes = sign * Math.floor(remaining / MS.m); remaining %= MS.m;
|
|
77
|
-
this._seconds = sign * Math.floor(remaining / MS.s); remaining %= MS.s;
|
|
78
|
-
this._milliseconds = sign * remaining;
|
|
79
|
-
this._weeks = 0;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// ── Getters ───────────────────────────────────────────────────────────────────
|
|
83
|
-
Duration.prototype.years = function() { return this._years; };
|
|
84
|
-
Duration.prototype.months = function() { return this._months; };
|
|
85
|
-
Duration.prototype.weeks = function() { return Math.floor(this._days/7); };
|
|
86
|
-
Duration.prototype.days = function() { return this._days % 7; };
|
|
87
|
-
Duration.prototype.hours = function() { return this._hours; };
|
|
88
|
-
Duration.prototype.minutes = function() { return this._minutes; };
|
|
89
|
-
Duration.prototype.seconds = function() { return this._seconds; };
|
|
90
|
-
Duration.prototype.milliseconds = function() { return this._milliseconds; };
|
|
91
|
-
|
|
92
|
-
// ── as() ─────────────────────────────────────────────────────────────────────
|
|
93
|
-
Duration.prototype.as = function(unit) {
|
|
94
|
-
var totalMs = this._toMs();
|
|
95
|
-
var multiplier = MS[unit] || 1;
|
|
96
|
-
return totalMs / multiplier;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
Duration.prototype.asMilliseconds = function() { return this._toMs(); };
|
|
100
|
-
Duration.prototype.asSeconds = function() { return this._toMs()/1000; };
|
|
101
|
-
Duration.prototype.asMinutes = function() { return this._toMs()/60000; };
|
|
102
|
-
Duration.prototype.asHours = function() { return this._toMs()/3600000; };
|
|
103
|
-
Duration.prototype.asDays = function() { return this._toMs()/86400000; };
|
|
104
|
-
Duration.prototype.asWeeks = function() { return this._toMs()/604800000; };
|
|
105
|
-
Duration.prototype.asMonths = function() { return this._toMs()/2629800000; };
|
|
106
|
-
Duration.prototype.asYears = function() { return this._toMs()/31557600000; };
|
|
107
|
-
|
|
108
|
-
Duration.prototype.get = function(unit) {
|
|
109
|
-
return this.as(unit);
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
// ── Add / Subtract ────────────────────────────────────────────────────────────
|
|
113
|
-
Duration.prototype.add = function(input, unit) {
|
|
114
|
-
var other = input instanceof Duration ? input : new Duration(input, unit);
|
|
115
|
-
this._years += other._years;
|
|
116
|
-
this._months += other._months;
|
|
117
|
-
this._weeks += other._weeks;
|
|
118
|
-
this._days += other._days;
|
|
119
|
-
this._hours += other._hours;
|
|
120
|
-
this._minutes += other._minutes;
|
|
121
|
-
this._seconds += other._seconds;
|
|
122
|
-
this._milliseconds+= other._milliseconds;
|
|
123
|
-
this._ms = this._toMs();
|
|
124
|
-
return this;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
Duration.prototype.subtract = function(input, unit) {
|
|
128
|
-
var other = input instanceof Duration ? input : new Duration(input, unit);
|
|
129
|
-
this._years -= other._years;
|
|
130
|
-
this._months -= other._months;
|
|
131
|
-
this._weeks -= other._weeks;
|
|
132
|
-
this._days -= other._days;
|
|
133
|
-
this._hours -= other._hours;
|
|
134
|
-
this._minutes -= other._minutes;
|
|
135
|
-
this._seconds -= other._seconds;
|
|
136
|
-
this._milliseconds-= other._milliseconds;
|
|
137
|
-
this._ms = this._toMs();
|
|
138
|
-
return this;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// ── Humanize ─────────────────────────────────────────────────────────────────
|
|
142
|
-
Duration.prototype.humanize = function(withSuffix) {
|
|
143
|
-
var ms = Math.abs(this._toMs());
|
|
144
|
-
var loc = localeModule.getLocale(this._locale);
|
|
145
|
-
var rt = loc.relativeTime;
|
|
146
|
-
var str;
|
|
147
|
-
|
|
148
|
-
var secs = ms/1000, mins = ms/60000, hrs = ms/3600000,
|
|
149
|
-
days = ms/86400000, weeks = ms/604800000,
|
|
150
|
-
months = ms/2629800000, years = ms/31557600000;
|
|
151
|
-
|
|
152
|
-
if (ms < 45000) str = rt.s;
|
|
153
|
-
else if (ms < 90000) str = rt.m;
|
|
154
|
-
else if (ms < 2700000) str = rt.mm.replace('%d', Math.round(mins));
|
|
155
|
-
else if (ms < 5400000) str = rt.h;
|
|
156
|
-
else if (ms < 79200000) str = rt.hh.replace('%d', Math.round(hrs));
|
|
157
|
-
else if (ms < 129600000)str = rt.d;
|
|
158
|
-
else if (ms < 2160000000)str = rt.dd.replace('%d', Math.round(days));
|
|
159
|
-
else if (ms < 3888000000)str = rt.M;
|
|
160
|
-
else if (ms < 31536000000)str = rt.MM.replace('%d', Math.round(months));
|
|
161
|
-
else if (ms < 47260800000)str = rt.y;
|
|
162
|
-
else str = rt.yy.replace('%d', Math.round(years));
|
|
163
|
-
|
|
164
|
-
if (withSuffix) {
|
|
165
|
-
if (this._toMs() >= 0) return rt.future.replace('%s', str);
|
|
166
|
-
return rt.past.replace('%s', str);
|
|
167
|
-
}
|
|
168
|
-
return str;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
Duration.prototype.locale = function(loc) {
|
|
172
|
-
this._locale = loc;
|
|
173
|
-
return this;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
// ── ISO string ────────────────────────────────────────────────────────────────
|
|
177
|
-
Duration.prototype.toISOString = function() {
|
|
178
|
-
var Y = this._years, M = this._months, W = this._weeks;
|
|
179
|
-
var D = this._days, H = this._hours, m = this._minutes, S = this._seconds;
|
|
180
|
-
return 'P' + (Y?Y+'Y':'') + (M?M+'M':'') + (W?W+'W':'') + (D?D+'D':'') +
|
|
181
|
-
((H||m||S)?('T'+(H?H+'H':'')+(m?m+'M':'')+(S?S+'S':'')):'') || 'P0D';
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
Duration.prototype.toJSON = Duration.prototype.toISOString;
|
|
185
|
-
Duration.prototype.valueOf = function() { return this._toMs(); };
|
|
186
|
-
Duration.prototype.clone = function() { return new Duration(this._toMs()); };
|
|
187
|
-
|
|
188
|
-
module.exports = Duration;
|
package/src/locale.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// ─── Default English Locale ───────────────────────────────────────────────────
|
|
4
|
-
var en = {
|
|
5
|
-
name: 'en',
|
|
6
|
-
months: ['January','February','March','April','May','June','July','August','September','October','November','December'],
|
|
7
|
-
monthsShort: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
|
|
8
|
-
weekdays: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
|
|
9
|
-
weekdaysShort: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],
|
|
10
|
-
weekdaysMin: ['Su','Mo','Tu','We','Th','Fr','Sa'],
|
|
11
|
-
longDateFormat: {
|
|
12
|
-
LT: 'h:mm A', LTS: 'h:mm:ss A',
|
|
13
|
-
L: 'MM/DD/YYYY', LL: 'MMMM D, YYYY',
|
|
14
|
-
LLL: 'MMMM D, YYYY h:mm A', LLLL: 'dddd, MMMM D, YYYY h:mm A'
|
|
15
|
-
},
|
|
16
|
-
calendar: {
|
|
17
|
-
sameDay: '[Today at] LT',
|
|
18
|
-
nextDay: '[Tomorrow at] LT',
|
|
19
|
-
nextWeek: 'dddd [at] LT',
|
|
20
|
-
lastDay: '[Yesterday at] LT',
|
|
21
|
-
lastWeek: '[Last] dddd [at] LT',
|
|
22
|
-
sameElse: 'L'
|
|
23
|
-
},
|
|
24
|
-
relativeTime: {
|
|
25
|
-
future: 'in %s',
|
|
26
|
-
past: '%s ago',
|
|
27
|
-
s: 'a few seconds', ss: '%d seconds',
|
|
28
|
-
m: 'a minute', mm: '%d minutes',
|
|
29
|
-
h: 'an hour', hh: '%d hours',
|
|
30
|
-
d: 'a day', dd: '%d days',
|
|
31
|
-
w: 'a week', ww: '%d weeks',
|
|
32
|
-
M: 'a month', MM: '%d months',
|
|
33
|
-
y: 'a year', yy: '%d years'
|
|
34
|
-
},
|
|
35
|
-
ordinal: function(n) {
|
|
36
|
-
var s=['th','st','nd','rd'], v=n%100;
|
|
37
|
-
return n+(s[(v-20)%10]||s[v]||s[0]);
|
|
38
|
-
},
|
|
39
|
-
week: { dow: 0, doy: 6 },
|
|
40
|
-
meridiem: function(h, m, isLower) {
|
|
41
|
-
return h < 12 ? (isLower ? 'am' : 'AM') : (isLower ? 'pm' : 'PM');
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// ─── Hindi Locale ─────────────────────────────────────────────────────────────
|
|
46
|
-
var hi = {
|
|
47
|
-
name: 'hi',
|
|
48
|
-
months: ['जनवरी','फ़रवरी','मार्च','अप्रैल','मई','जून','जुलाई','अगस्त','सितंबर','अक्टूबर','नवंबर','दिसंबर'],
|
|
49
|
-
monthsShort: ['जन.','फ़र.','मार्च','अप्रै.','मई','जून','जुल.','अग.','सित.','अक्टू.','नव.','दिस.'],
|
|
50
|
-
weekdays: ['रविवार','सोमवार','मंगलवार','बुधवार','गुरूवार','शुक्रवार','शनिवार'],
|
|
51
|
-
weekdaysShort: ['रवि','सोम','मंगल','बुध','गुरू','शुक्र','शनि'],
|
|
52
|
-
weekdaysMin: ['र','सो','मं','बु','गु','शु','श'],
|
|
53
|
-
longDateFormat: { LT:'A h:mm बजे', LTS:'A h:mm:ss बजे', L:'DD/MM/YYYY', LL:'D MMMM YYYY', LLL:'D MMMM YYYY, A h:mm बजे', LLLL:'dddd, D MMMM YYYY, A h:mm बजे' },
|
|
54
|
-
calendar: { sameDay:'[आज] LT', nextDay:'[कल] LT', nextWeek:'dddd[,] LT', lastDay:'[कल] LT', lastWeek:'[पिछले] dddd[,] LT', sameElse:'L' },
|
|
55
|
-
relativeTime: { future:'%s में', past:'%s पहले', s:'कुछ ही क्षण', ss:'%d सेकंड', m:'एक मिनट', mm:'%d मिनट', h:'एक घंटा', hh:'%d घंटे', d:'एक दिन', dd:'%d दिन', w:'एक सप्ताह', ww:'%d सप्ताह', M:'एक महीने', MM:'%d महीने', y:'एक वर्ष', yy:'%d वर्ष' },
|
|
56
|
-
ordinal: function(n) { return n; },
|
|
57
|
-
week: { dow: 0, doy: 6 },
|
|
58
|
-
meridiem: function(h) { if(h<4) return 'रात'; if(h<10) return 'सुबह'; if(h<17) return 'दोपहर'; if(h<20) return 'शाम'; return 'रात'; }
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// ─── Spanish Locale ───────────────────────────────────────────────────────────
|
|
62
|
-
var es = {
|
|
63
|
-
name: 'es',
|
|
64
|
-
months: ['enero','febrero','marzo','abril','mayo','junio','julio','agosto','septiembre','octubre','noviembre','diciembre'],
|
|
65
|
-
monthsShort: ['ene.','feb.','mar.','abr.','may.','jun.','jul.','ago.','sep.','oct.','nov.','dic.'],
|
|
66
|
-
weekdays: ['domingo','lunes','martes','miércoles','jueves','viernes','sábado'],
|
|
67
|
-
weekdaysShort: ['dom.','lun.','mar.','mié.','jue.','vie.','sáb.'],
|
|
68
|
-
weekdaysMin: ['do','lu','ma','mi','ju','vi','sá'],
|
|
69
|
-
longDateFormat: { LT:'H:mm', LTS:'H:mm:ss', L:'DD/MM/YYYY', LL:'D [de] MMMM [de] YYYY', LLL:'D [de] MMMM [de] YYYY H:mm', LLLL:'dddd, D [de] MMMM [de] YYYY H:mm' },
|
|
70
|
-
calendar: { sameDay:'[hoy a la' , nextDay:'[mañana a la', nextWeek:'dddd [a la', lastDay:'[ayer a la', lastWeek:'[el] dddd [pasado a la', sameElse:'L' },
|
|
71
|
-
relativeTime: { future:'en %s', past:'hace %s', s:'unos segundos', ss:'%d segundos', m:'un minuto', mm:'%d minutos', h:'una hora', hh:'%d horas', d:'un día', dd:'%d días', w:'una semana', ww:'%d semanas', M:'un mes', MM:'%d meses', y:'un año', yy:'%d años' },
|
|
72
|
-
ordinal: function(n) { return n+'º'; },
|
|
73
|
-
week: { dow: 1, doy: 4 },
|
|
74
|
-
meridiem: function(h,m,isLower) { return h<12?(isLower?'am':'AM'):(isLower?'pm':'PM'); }
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// ─── French ──────────────────────────────────────────────────────────────────
|
|
78
|
-
var fr = {
|
|
79
|
-
name: 'fr',
|
|
80
|
-
months: ['janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novembre','décembre'],
|
|
81
|
-
monthsShort: ['janv.','févr.','mars','avr.','mai','juin','juil.','août','sept.','oct.','nov.','déc.'],
|
|
82
|
-
weekdays: ['dimanche','lundi','mardi','mercredi','jeudi','vendredi','samedi'],
|
|
83
|
-
weekdaysShort: ['dim.','lun.','mar.','mer.','jeu.','ven.','sam.'],
|
|
84
|
-
weekdaysMin: ['di','lu','ma','me','je','ve','sa'],
|
|
85
|
-
longDateFormat: { LT:'HH:mm', LTS:'HH:mm:ss', L:'DD/MM/YYYY', LL:'D MMMM YYYY', LLL:'D MMMM YYYY HH:mm', LLLL:'dddd D MMMM YYYY HH:mm' },
|
|
86
|
-
calendar: { sameDay:"[Aujourd'hui à] LT", nextDay:'[Demain à] LT', nextWeek:'dddd [à] LT', lastDay:'[Hier à] LT', lastWeek:'dddd [dernier à] LT', sameElse:'L' },
|
|
87
|
-
relativeTime: { future:'dans %s', past:'il y a %s', s:'quelques secondes', ss:'%d secondes', m:'une minute', mm:'%d minutes', h:'une heure', hh:'%d heures', d:'un jour', dd:'%d jours', w:'une semaine', ww:'%d semaines', M:'un mois', MM:'%d mois', y:'un an', yy:'%d ans' },
|
|
88
|
-
ordinal: function(n) { return n+(n===1?'er':'e'); },
|
|
89
|
-
week: { dow: 1, doy: 4 },
|
|
90
|
-
meridiem: function(h,m,isLower) { return h<12?(isLower?'am':'AM'):(isLower?'pm':'PM'); }
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// ─── German ───────────────────────────────────────────────────────────────────
|
|
94
|
-
var de = {
|
|
95
|
-
name: 'de',
|
|
96
|
-
months: ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],
|
|
97
|
-
monthsShort: ['Jan.','Feb.','März','Apr.','Mai','Juni','Juli','Aug.','Sep.','Okt.','Nov.','Dez.'],
|
|
98
|
-
weekdays: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
|
|
99
|
-
weekdaysShort: ['So.','Mo.','Di.','Mi.','Do.','Fr.','Sa.'],
|
|
100
|
-
weekdaysMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
|
|
101
|
-
longDateFormat: { LT:'HH:mm', LTS:'HH:mm:ss', L:'DD.MM.YYYY', LL:'D. MMMM YYYY', LLL:'D. MMMM YYYY HH:mm', LLLL:'dddd, D. MMMM YYYY HH:mm' },
|
|
102
|
-
calendar: { sameDay:'[heute um] LT [Uhr]', nextDay:'[morgen um] LT [Uhr]', nextWeek:'dddd [um] LT [Uhr]', lastDay:'[gestern um] LT [Uhr]', lastWeek:'[letzten] dddd [um] LT [Uhr]', sameElse:'L' },
|
|
103
|
-
relativeTime: { future:'in %s', past:'vor %s', s:'ein paar Sekunden', ss:'%d Sekunden', m:'einer Minute', mm:'%d Minuten', h:'einer Stunde', hh:'%d Stunden', d:'einem Tag', dd:'%d Tagen', w:'einer Woche', ww:'%d Wochen', M:'einem Monat', MM:'%d Monaten', y:'einem Jahr', yy:'%d Jahren' },
|
|
104
|
-
ordinal: function(n) { return n+'.'; },
|
|
105
|
-
week: { dow: 1, doy: 4 },
|
|
106
|
-
meridiem: function(h,m,isLower) { return h<12?(isLower?'am':'AM'):(isLower?'pm':'PM'); }
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
// ─── Arabic ───────────────────────────────────────────────────────────────────
|
|
110
|
-
var ar = {
|
|
111
|
-
name: 'ar',
|
|
112
|
-
months: ['يناير','فبراير','مارس','أبريل','مايو','يونيو','يوليو','أغسطس','سبتمبر','أكتوبر','نوفمبر','ديسمبر'],
|
|
113
|
-
monthsShort: ['يناير','فبراير','مارس','أبريل','مايو','يونيو','يوليو','أغسطس','سبتمبر','أكتوبر','نوفمبر','ديسمبر'],
|
|
114
|
-
weekdays: ['الأحد','الاثنين','الثلاثاء','الأربعاء','الخميس','الجمعة','السبت'],
|
|
115
|
-
weekdaysShort: ['أحد','اثنين','ثلاثاء','أربعاء','خميس','جمعة','سبت'],
|
|
116
|
-
weekdaysMin: ['ح','ن','ث','ر','خ','ج','س'],
|
|
117
|
-
longDateFormat: { LT:'HH:mm', LTS:'HH:mm:ss', L:'DD/MM/YYYY', LL:'D MMMM YYYY', LLL:'D MMMM YYYY HH:mm', LLLL:'dddd D MMMM YYYY HH:mm' },
|
|
118
|
-
calendar: { sameDay:'[اليوم عند الساعة] LT', nextDay:'[غدًا عند الساعة] LT', nextWeek:'dddd [عند الساعة] LT', lastDay:'[أمس عند الساعة] LT', lastWeek:'dddd [عند الساعة] LT', sameElse:'L' },
|
|
119
|
-
relativeTime: { future:'في %s', past:'منذ %s', s:'ثوان', ss:'%d ثانية', m:'دقيقة', mm:'%d دقائق', h:'ساعة', hh:'%d ساعات', d:'يوم', dd:'%d أيام', w:'أسبوع', ww:'%d أسابيع', M:'شهر', MM:'%d أشهر', y:'سنة', yy:'%d سنوات' },
|
|
120
|
-
ordinal: function(n) { return n; },
|
|
121
|
-
week: { dow: 6, doy: 12 },
|
|
122
|
-
meridiem: function(h,m,isLower) { return h<12?(isLower?'ص':'ص'):(isLower?'م':'م'); }
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// ─── Japanese ─────────────────────────────────────────────────────────────────
|
|
126
|
-
var ja = {
|
|
127
|
-
name: 'ja',
|
|
128
|
-
months: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
|
|
129
|
-
monthsShort: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
|
|
130
|
-
weekdays: ['日曜日','月曜日','火曜日','水曜日','木曜日','金曜日','土曜日'],
|
|
131
|
-
weekdaysShort: ['日','月','火','水','木','金','土'],
|
|
132
|
-
weekdaysMin: ['日','月','火','水','木','金','土'],
|
|
133
|
-
longDateFormat: { LT:'HH:mm', LTS:'HH:mm:ss', L:'YYYY/MM/DD', LL:'YYYY年M月D日', LLL:'YYYY年M月D日 HH:mm', LLLL:'YYYY年M月D日 dddd HH:mm' },
|
|
134
|
-
calendar: { sameDay:'[今日] LT', nextDay:'[明日] LT', nextWeek:'[来週]dddd LT', lastDay:'[昨日] LT', lastWeek:'[前週]dddd LT', sameElse:'L' },
|
|
135
|
-
relativeTime: { future:'%s後', past:'%s前', s:'数秒', ss:'%d秒', m:'1分', mm:'%d分', h:'1時間', hh:'%d時間', d:'1日', dd:'%d日', w:'1週間', ww:'%d週間', M:'1ヶ月', MM:'%dヶ月', y:'1年', yy:'%d年' },
|
|
136
|
-
ordinal: function(n) { return n; },
|
|
137
|
-
week: { dow: 0, doy: 6 },
|
|
138
|
-
meridiem: function(h) { return h<12?'午前':'午後'; }
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// ─── Locale Registry ─────────────────────────────────────────────────────────
|
|
142
|
-
var locales = { en: en, hi: hi, es: es, fr: fr, de: de, ar: ar, ja: ja };
|
|
143
|
-
var globalLocale = 'en';
|
|
144
|
-
|
|
145
|
-
function getLocale(name) {
|
|
146
|
-
return locales[name] || locales['en'];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function setGlobalLocale(name) {
|
|
150
|
-
if (locales[name]) globalLocale = name;
|
|
151
|
-
return globalLocale;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function getGlobalLocale() {
|
|
155
|
-
return globalLocale;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function getGlobalLocaleData() {
|
|
159
|
-
return locales[globalLocale];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function defineLocale(name, config) {
|
|
163
|
-
locales[name] = config;
|
|
164
|
-
config.name = name;
|
|
165
|
-
return config;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function listLocales() {
|
|
169
|
-
return Object.keys(locales);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
module.exports = {
|
|
173
|
-
getLocale: getLocale,
|
|
174
|
-
setGlobalLocale: setGlobalLocale,
|
|
175
|
-
getGlobalLocale: getGlobalLocale,
|
|
176
|
-
getGlobalLocaleData: getGlobalLocaleData,
|
|
177
|
-
defineLocale: defineLocale,
|
|
178
|
-
listLocales: listLocales
|
|
179
|
-
};
|