-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdate.ts
More file actions
30 lines (27 loc) · 658 Bytes
/
date.ts
File metadata and controls
30 lines (27 loc) · 658 Bytes
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
/// <reference path="typings/com.ibm.domino.d.ts" />
"use amd";
import * as util from "util";
export function add(date: Date): Date {
throw "Not implemented";
}
export function format(date: Date, format: string): string {
var [d,m,y] = [date.getDate(), date.getMonth()+1, date.getFullYear()];
return util.map(format.split(""), function (el) {
switch (el) {
case "d":
return d + "";
case "D":
return util.padleft(d, 2, "0");
case "m":
return m + "";
case "M":
return util.padleft(m, 2, "0");
case "y":
return y + "";
case "Y":
return util.padleft(y, 4, "0");
default:
return el + "";
}
}).join("")
}