Add 12-hour format (hh) and AM/PM (a) tokens to time formatter
This commit is contained in:
1 parent
c2996e4762
commit
dc41cabe4d
1 file changed
+8
@@ -832,6 +832,14 @@ var effect = (VANTA.CLOUDS2 || VANTA.CLOUDS)({
|
||||
} else if (ch === 'H' && format.substr(i, 2) === 'HH') {
|
||||
result += pad2(date.getHours());
|
||||
i += 2;
|
||||
} else if (ch === 'h' && format.substr(i, 2) === 'hh') {
|
||||
var h12 = date.getHours() % 12;
|
||||
if (h12 === 0) h12 = 12;
|
||||
result += pad2(h12);
|
||||
i += 2;
|
||||
} else if (ch === 'a') {
|
||||
result += date.getHours() < 12 ? 'AM' : 'PM';
|
||||
i += 1;
|
||||
} else if (ch === 'm' && format.substr(i, 2) === 'mm') {
|
||||
result += pad2(date.getMinutes());
|
||||
i += 2;
|
||||
|
||||
Reference in new issue
Block a user