diff --git a/include/class.misc.php b/include/class.misc.php index d8f2523045c2628f0fe796ace96ed44e761549ae..9b706168db939d6cf30b9b721e3ec1c9fa98c95b 100644 --- a/include/class.misc.php +++ b/include/class.misc.php @@ -86,23 +86,15 @@ class Misc { $tz = new DateTimeZone($cfg->getTimezone($user)); - if (!$timestamp) - $timestamp = 'now'; - - if (is_int($timestamp)) { - $time = $timestamp; - } else { - if (!($date = new DateTime($timestamp, $tz))) { - // Timestamp might be invalid + if ($timestamp && is_int($timestamp)) { + if (!($date = DateTime::createFromFormat('U', $timestamp))) return $timestamp; - } - $time = $date->format('U'); - } - if (!($D = DateTime::createFromFormat('U', $time))) - return $time; + return $timestamp - $tz->getOffset($date); + } - return $time - $tz->getOffset($D); + $date = new DateTime($timestamp ?: 'now', $tz); + return $date ? $date->getTimestamp() : $timestamp; } //Take user time or gmtime and return db (mysql) time. @@ -131,10 +123,14 @@ class Misc { global $cfg; $tz = new DateTimeZone($user ? $cfg->getDbTimezone($user) : 'UTC'); - if (!($time = new DateTime($time ?: 'now'))) { + + if ($time && is_numeric($time)) + $time = DateTime::createFromFormat('U', $time); + elseif (!($time = new DateTime($time ?: 'now'))) { // Old standard return time() - date('Z'); } + return $time->getTimestamp() - $tz->getOffset($time); } @@ -189,15 +185,16 @@ class Misc { else $min=0; + $time = Misc::user2gmtime(mktime(0,0,0)); ob_start(); echo sprintf('<select name="%s" id="%s" style="display:inline-block;width:auto">',$name,$name); echo '<option value="" selected>'.__('Time').'</option>'; for($i=23; $i>=0; $i--) { - for($minute=45; $minute>=0; $minute-=15) { + for ($minute=45; $minute>=0; $minute-=15) { $sel=($hr==$i && $min==$minute)?'selected="selected"':''; $_minute=str_pad($minute, 2, '0',STR_PAD_LEFT); $_hour=str_pad($i, 2, '0',STR_PAD_LEFT); - $disp = Format::time($i*3600 + $minute*60 + 1); + $disp = Format::time($time + ($i*3600 + $minute*60 + 1), false); echo sprintf('<option value="%s:%s" %s>%s</option>',$_hour,$_minute,$sel,$disp); } } diff --git a/include/class.ticket.php b/include/class.ticket.php index 79c56e77fe05dcc4fdbbec4f7dd6e309d41d0014..8f5dd5551bc713fa6d10bb8340806caf1f58317a 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -587,16 +587,22 @@ implements RestrictedAccess, Threadable { } function getUpdateInfo() { + global $cfg; + return array( 'source' => $this->getSource(), 'topicId' => $this->getTopicId(), 'slaId' => $this->getSLAId(), 'user_id' => $this->getOwnerId(), 'duedate' => $this->getDueDate() - ? Format::date($this->getDueDate()) + ? Format::date($this->getDueDate(), true, + $cfg->getDateFormat(true)) + : '', + 'time' => $this->getDueDate() + ? Format::time($this->getDueDate(), true, 'HH:mm') : '', - 'time' => $this->getDueDate()?(Format::date($this->getDueDate(), true, 'HH:mm')):'', ); + } function getLock() { diff --git a/scp/js/scp.js b/scp/js/scp.js index 2e6a116be5b998e44cf4ae812e2314c095cce14b..1e2dfa304ef14df52bd445a9bbb91e4797dc2b29 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -542,6 +542,7 @@ $.translate_format = function(str) { 'yyyy': '`', 'yyy': '`', 'yy': 'y', + 'y': 'yy', '`': 'yy' }; // Change PHP formats to datepicker ones