-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDateEx.gs
More file actions
57 lines (49 loc) · 1.42 KB
/
DateEx.gs
File metadata and controls
57 lines (49 loc) · 1.42 KB
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
56
57
/**
* 日時変換クラス
* 0詰め対応
* @override
*/
function DateEx(date) {
if (date === undefined) {
this.d = new Date();
}
else {
this.d = new Date(date);
}
}
DateEx.prototype.getFullYear = function() {
return this.d.getFullYear();
};
DateEx.prototype.getMonth = function() {
return ((this.d.getMonth() + 1).toString().length == 1) ? ('0' + (this.d.getMonth() + 1)) : (this.d.getMonth() + 1);
};
DateEx.prototype.getDate = function() {
return (this.d.getDate().toString().length == 1) ? ('0' + this.d.getDate()) : this.d.getDate();
};
DateEx.prototype.getHours = function() {
return (this.d.getHours().toString().length == 1) ? ('0' + this.d.getHours()) : this.d.getHours();
};
DateEx.prototype.getMinutes = function() {
return (this.d.getMinutes().toString().length == 1) ? ('0' + this.d.getMinutes()) : this.d.getMinutes();
};
DateEx.prototype.getSeconds = function() {
return (this.d.getSeconds().toString().length == 1) ? ('0' + this.d.getSeconds()) : this.d.getSeconds();
};
/**
* 年月日文字列を取得
*/
DateEx.prototype.getDateStr = function(sep) {
if (sep === undefined) {
sep = '/';
}
return this.getFullYear() + sep + this.getMonth() + sep + this.getDate();
};
/**
* 時分秒文字列を取得
*/
DateEx.prototype.getTimeStr = function(sep) {
if (sep === undefined) {
sep = ':';
}
return this.getHours() + sep + this.getMinutes() + sep + this.getSeconds();
};