-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
moment-strftime.js
55 lines (48 loc) · 972 Bytes
/
moment-strftime.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(function () {
var moment, replacements;
if (typeof require !== "undefined" && require !== null) {
moment = require('moment');
} else {
moment = this.moment;
}
replacements = {
a: 'ddd',
A: 'dddd',
b: 'MMM',
B: 'MMMM',
d: 'DD',
e: 'D',
F: 'YYYY-MM-DD',
H: 'HH',
I: 'hh',
j: 'DDDD',
k: 'H',
l: 'h',
m: 'MM',
M: 'mm',
p: 'A',
S: 'ss',
u: 'E',
w: 'd',
W: 'WW',
y: 'YY',
Y: 'YYYY',
z: 'ZZ',
Z: 'z',
'%': '%'
};
moment.fn.strftime = function (format) {
var momentFormat, value;
momentFormat = format;
Object.keys(replacements).forEach(function (key) {
value = replacements[key];
momentFormat = momentFormat.replace("%" + key, value);
});
return this.format(momentFormat);
};
if (typeof module !== "undefined" && module !== null) {
module.exports = moment;
} else {
this.moment = moment;
}
}).call(this);