Add: get full(year, month, ... , seconds) methods for time

This commit is contained in:
2019-06-05 11:45:54 +09:00
parent 52275e0bc7
commit e6d23dd61b
2 changed files with 55 additions and 14 deletions
+32 -7
View File
@@ -1,16 +1,41 @@
function DateUtil() {
}
DateUtil.getFullYear = function(date) {
return date.getFullYear();
}
DateUtil.getFullMonth = function(date) {
return StringUtil.getNumberStartWithZero(date.getMonth() + 1, 2)
}
DateUtil.getFullDate = function(date) {
return StringUtil.getNumberStartWithZero(date.getDate(), 2);
}
DateUtil.getFullHours = function(date) {
return StringUtil.getNumberStartWithZero(date.getHours(), 2);
}
DateUtil.getFullMinutes = function(date) {
return StringUtil.getNumberStartWithZero(date.getMinutes(), 2);
}
DateUtil.getFullSeconds = function(date) {
return StringUtil.getNumberStartWithZero(date.getSeconds(), 2);
}
DateUtil.getYYYYMMDD = function(date) {
// return date.toISOString().slice(0,10);
var yymmdd = date.getFullYear() + "-"
+ ("0" + (date.getMonth() + 1)).slice(-2) + "-"
+ ("0" + date.getDate()).slice(-2);
return yymmdd;
return DateUtil.getFullYear(date) + "-"
+ DateUtil.getFullMonth(date) + "-"
+ DateUtil.getFullDate(date);
}
DateUtil.getHHMMSS = function(date) {
return StringUtil.getNumberStartWithZero(date.getHours(), 2) + ":"
+ StringUtil.getNumberStartWithZero(date.getMinutes(), 2) + ":"
+ StringUtil.getNumberStartWithZero(date.getSeconds(), 2);
return DateUtil.getFullHours(date) + ":"
+ DateUtil.getFullMinutes(date) + ":"
+ DateUtil.getFullSeconds(date);
}