Relative local time
This commit is contained in:
16
inc/Spot.php
16
inc/Spot.php
@@ -117,7 +117,7 @@ class Spot extends Main
|
|||||||
'site_time' => "TIMESTAMP DEFAULT 0", //DEFAULT 0 removes auto-set to current time
|
'site_time' => "TIMESTAMP DEFAULT 0", //DEFAULT 0 removes auto-set to current time
|
||||||
'status' => "VARCHAR(10)",
|
'status' => "VARCHAR(10)",
|
||||||
'taken_on' => "TIMESTAMP DEFAULT 0",
|
'taken_on' => "TIMESTAMP DEFAULT 0",
|
||||||
'timezone' => "CHAR(64)", //see mysql.time_zone_name
|
'timezone' => "CHAR(64) NOT NULL", //see mysql.time_zone_name
|
||||||
'token' => "VARCHAR(4096)",
|
'token' => "VARCHAR(4096)",
|
||||||
'type' => "VARCHAR(20)",
|
'type' => "VARCHAR(20)",
|
||||||
'unix_time' => "INT",
|
'unix_time' => "INT",
|
||||||
@@ -428,7 +428,11 @@ class Spot extends Main
|
|||||||
$asData['unix_time'] = (int) $iTime;
|
$asData['unix_time'] = (int) $iTime;
|
||||||
$asData['relative_time'] = Toolbox::getDateTimeDesc($iTime, $this->oLang->getLanguage());
|
$asData['relative_time'] = Toolbox::getDateTimeDesc($iTime, $this->oLang->getLanguage());
|
||||||
$asData['formatted_time'] = $this->getTimeFormat($iTime);
|
$asData['formatted_time'] = $this->getTimeFormat($iTime);
|
||||||
if($sTimeZone != '') $asData['formatted_time_local'] = $this->getTimeFormat($iTime, $sTimeZone);
|
|
||||||
|
if($sTimeZone != '') {
|
||||||
|
$asData['formatted_time_local'] = $this->getTimeFormat($iTime, $sTimeZone);
|
||||||
|
$asData['day_offset'] = self::getTimeZoneDayOffset($iTime, $sTimeZone);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getFeedConstraints($sType, $sTimeField='site_time', $sReturnFormat='array') {
|
private function getFeedConstraints($sType, $sTimeField='site_time', $sReturnFormat='array') {
|
||||||
@@ -773,6 +777,14 @@ class Spot extends Main
|
|||||||
return $this->oLang->getTranslation('date_time', array($sDate, $sTime));
|
return $this->oLang->getTranslation('date_time', array($sDate, $sTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getTimeZoneDayOffset($iTime, $sLocalTimeZone) {
|
||||||
|
$sSiteTimeZone = date_default_timezone_get();
|
||||||
|
$iLocalDate = (int) (new \DateTime('@'.$iTime))->setTimezone(new \DateTimeZone($sLocalTimeZone))->format('Ymd');
|
||||||
|
$iSiteDate = (int) (new \DateTime('@'.$iTime))->setTimezone(new \DateTimeZone($sSiteTimeZone ))->format('Ymd');
|
||||||
|
|
||||||
|
return ($iLocalDate == $iSiteDate)?'0':(($iLocalDate > $iSiteDate)?'+1':'-1');
|
||||||
|
}
|
||||||
|
|
||||||
public static function getTimeZoneFromDate($sDate) {
|
public static function getTimeZoneFromDate($sDate) {
|
||||||
$sTimeZone = null;
|
$sTimeZone = null;
|
||||||
|
|
||||||
|
|||||||
@@ -669,7 +669,7 @@ function addSpotMessages(aoMessages) {
|
|||||||
if(oMsg.formatted_time_local != oMsg.formatted_time) {
|
if(oMsg.formatted_time_local != oMsg.formatted_time) {
|
||||||
$Tooltip.append($('<p>', {'class':'timezone'})
|
$Tooltip.append($('<p>', {'class':'timezone'})
|
||||||
.addIcon('fa-timezone fa-fw fa-lg', true)
|
.addIcon('fa-timezone fa-fw fa-lg', true)
|
||||||
.append(oSpot.lang('local_time', oMsg.formatted_time_local)));
|
.append(oSpot.lang('local_time', getRelativeTime(oMsg.formatted_time_local, oMsg.day_offset))));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Weather
|
//Weather
|
||||||
@@ -853,6 +853,12 @@ function focusOnPost(oFocusPost) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRelativeTime(sLocalTime, iOffset) {
|
||||||
|
let $Time = $('<span>').text(sLocalTime.substr(-5));
|
||||||
|
if(iOffset != '0') $Time.append($('<sup>', {'title': iOffset+' '+oSpot.lang('unit_day')+' ('+sLocalTime.substr(0, 5)+')'}).text(' '+iOffset));
|
||||||
|
return $Time.html();
|
||||||
|
}
|
||||||
|
|
||||||
function getPost(asPost) {
|
function getPost(asPost) {
|
||||||
asPost.headerless = asPost.headerless || false;
|
asPost.headerless = asPost.headerless || false;
|
||||||
var bLink = false;
|
var bLink = false;
|
||||||
@@ -877,7 +883,7 @@ function getPost(asPost) {
|
|||||||
.data('clicked', false)
|
.data('clicked', false)
|
||||||
.append($('<p>').addIcon('fa-coords', true).append(getGoogleMapsLink(asPost)))
|
.append($('<p>').addIcon('fa-coords', true).append(getGoogleMapsLink(asPost)))
|
||||||
.append($('<p>').addIcon('fa-time', true).append(sAbsTime))
|
.append($('<p>').addIcon('fa-time', true).append(sAbsTime))
|
||||||
.append(bTimeDiff?$('<p>').addIcon('fa-timezone', true).append(oSpot.lang('local_time', sAbsTimeLocal)):'')
|
.append(bTimeDiff?$('<p>').addIcon('fa-timezone', true).append(oSpot.lang('local_time', getRelativeTime(sAbsTimeLocal, asPost.day_offset))):'')
|
||||||
.append($('<a>', {'class':'drill'})
|
.append($('<a>', {'class':'drill'})
|
||||||
.append((!asPost.weather_icon || asPost.weather_icon=='unknown')?'':$('<span>', {'class':'weather', 'title':oSpot.lang(asPost.weather_cond)}).addIcon('fa-'+asPost.weather_icon).append($('<span>').text(asPost.weather_temp+'°C')))
|
.append((!asPost.weather_icon || asPost.weather_icon=='unknown')?'':$('<span>', {'class':'weather', 'title':oSpot.lang(asPost.weather_cond)}).addIcon('fa-'+asPost.weather_icon).append($('<span>').text(asPost.weather_temp+'°C')))
|
||||||
.append($('<img>', {'class':'staticmap', title: oSpot.lang('click_zoom'), src: asPost.static_img_url}))
|
.append($('<img>', {'class':'staticmap', title: oSpot.lang('click_zoom'), src: asPost.static_img_url}))
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ function Spot(asGlobals)
|
|||||||
|
|
||||||
this.checkClearance = function(sClearance) {
|
this.checkClearance = function(sClearance) {
|
||||||
return (self.vars(['user', 'clearance']) >= sClearance);
|
return (self.vars(['user', 'clearance']) >= sClearance);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Common Functions */
|
/* Common Functions */
|
||||||
|
|||||||
Reference in New Issue
Block a user