diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-10-17 15:33:13 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-10-17 15:33:13 -0700 |
commit | 24fadac198c7a37ee5341ef1bcf8764eb6ce9314 (patch) | |
tree | bee71952f429f57df67ae68cee5bc370d47d76af /system/admin/static/common/js/util.js | |
parent | e82ae68634df85b06ff816525aa64a72ac9d8771 (diff) |
adding util for date and time parsing, adding js to set inputs to time and date values based on timestamp
Diffstat (limited to 'system/admin/static/common/js/util.js')
-rw-r--r-- | system/admin/static/common/js/util.js | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/system/admin/static/common/js/util.js b/system/admin/static/common/js/util.js index 1e798d6..40c9828 100644 --- a/system/admin/static/common/js/util.js +++ b/system/admin/static/common/js/util.js @@ -23,12 +23,34 @@ function replaceBadChars(text) { } -// Returns a local partial time based on unix timestamp -function getPartialTime(date) { +// Returns a local partial time based on unix timestamp (i.e. HH:MM:SS) +function getPartialTime(unix) { + var date = new Date(unix); var parts = []; - parts.push(date.getHours()) - parts.push(date.getMinutes()) - parts.push(date.getSeconds()) + parts.push(date.getHours()); + parts.push(date.getMinutes()); + parts.push(date.getSeconds()); return parts.join(":"); +} + +// Returns a local partial date based on unix timestamp (YYYY-MM-DD) +function getPartialDate(unix) { + var date = new Date(unix); + var parts = []; + parts.push(date.getFullYear()); + + var month = date.getMonth()+1; + if (month < 10) { + month = "0" + String(month); + } + parts.push(month); + + var day = date.getDate(); + if (day < 10) { + day = "0" + String(day); + } + parts.push(day); + + return parts.join("-"); }
\ No newline at end of file |