diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-10-17 16:43:51 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-10-17 16:43:51 -0700 |
commit | 884d364476565b1f94b1bdf3e85f92d7d8081f6c (patch) | |
tree | 312b74027156559f0f1504e156709e57255d05a4 /system/admin/static/common/js | |
parent | 36a5a1065f782355f7c95f7ae2cee2ee817afcc4 (diff) |
modifying form to support more browsers w/o input[type=time]
Diffstat (limited to 'system/admin/static/common/js')
-rw-r--r-- | system/admin/static/common/js/util.js | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/system/admin/static/common/js/util.js b/system/admin/static/common/js/util.js index 40c9828..cf47af4 100644 --- a/system/admin/static/common/js/util.js +++ b/system/admin/static/common/js/util.js @@ -23,34 +23,42 @@ function replaceBadChars(text) { } -// Returns a local partial time based on unix timestamp (i.e. HH:MM:SS) +// Returns a local partial time object based on unix timestamp function getPartialTime(unix) { var date = new Date(unix); - var parts = []; - parts.push(date.getHours()); - parts.push(date.getMinutes()); - parts.push(date.getSeconds()); + var t = {}; + var hours = date.getHours(); + if (hours < 10) { + hours = "0" + String(hours); + } + t.hh = hours; + + var minutes = date.getMinutes(); + if (minutes < 10) { + minutes = "0" + String(minutes); + } + t.mm = minutes; - return parts.join(":"); + return t; } -// Returns a local partial date based on unix timestamp (YYYY-MM-DD) +// Returns a local partial date object based on unix timestamp function getPartialDate(unix) { var date = new Date(unix); - var parts = []; - parts.push(date.getFullYear()); + var d = {}; + d.yyyy = date.getFullYear(); var month = date.getMonth()+1; if (month < 10) { month = "0" + String(month); } - parts.push(month); + d.mm = month; var day = date.getDate(); if (day < 10) { day = "0" + String(day); } - parts.push(day); + d.dd = day; - return parts.join("-"); + return d; }
\ No newline at end of file |