From 884d364476565b1f94b1bdf3e85f92d7d8081f6c Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Mon, 17 Oct 2016 16:43:51 -0700 Subject: modifying form to support more browsers w/o input[type=time] --- system/admin/static/common/js/util.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'system/admin/static/common/js/util.js') 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 -- cgit v1.2.3