diff --git a/inc/Media.php b/inc/Media.php index 5ee2ad7..8157637 100644 --- a/inc/Media.php +++ b/inc/Media.php @@ -120,11 +120,12 @@ class Media extends PhpObject { else { $asMediaInfo = $this->getMediaInfoFromFile($sMediaName); - //Converting times to DB Time Zone, by using date() + //Converting times to Site Time Zone, by using date() + //Media Timezone is kept in a separate field for later conversion to Local Time $asDbInfo = array( Db::getId(Project::PROJ_TABLE) => $this->oProject->getProjectId(), 'filename' => $sMediaName, - 'taken_on' => ($asMediaInfo['taken_ts'] > 0)?date(Db::TIMESTAMP_FORMAT, $asMediaInfo['taken_ts']):'0000-00-00 00:00:00', + 'taken_on' => date(Db::TIMESTAMP_FORMAT, ($asMediaInfo['taken_ts'] > 0)?$asMediaInfo['taken_ts']:$asMediaInfo['file_ts']), 'posted_on' => date(Db::TIMESTAMP_FORMAT, $asMediaInfo['file_ts']), 'timezone' => $asMediaInfo['timezone'], 'width' => $asMediaInfo['width'], @@ -151,7 +152,6 @@ class Media extends PhpObject { $sMediaPath = self::getMediaPath($sMediaName); $sType = self::getMediaType($sMediaName); - $iTimeStamp = $iTakenOn = 0; $iPostedOn = filemtime($sMediaPath); $sTimeZone = date_default_timezone_get(); $iWidth = 0; @@ -224,16 +224,13 @@ class Media extends PhpObject { //Assign the correct Time Zone to $sTakenOn if it is not already contained in it. Then get Unix Timestamp //Time Zone (2nd parameter) will be ignored if already contained in $sTakenOn + $iTakenOn = 0; if($sTakenOn != '') { $oTakenOn = new \DateTime($sTakenOn, new \DateTimeZone($sTimeZone)); $iTakenOn = $oTakenOn->format('U'); } - //Merge timestamps - $iTimeStamp = ($iTakenOn > 0)?$iTakenOn:$iPostedOn; - return array( - 'timestamp' => $iTimeStamp, 'timezone' => $sTimeZone, 'taken_ts' => $iTakenOn, 'file_ts' => $iPostedOn, diff --git a/inc/Spot.php b/inc/Spot.php index 35d8df7..f0bd7ee 100755 --- a/inc/Spot.php +++ b/inc/Spot.php @@ -10,20 +10,24 @@ use \Settings; /* Timezones * --------- - * Site Time: Time Zone in which the User is viewing the Site (default PHP/SQL Timezone) - * Local Time: Time Zone in which the Spot Owner is + * Site Time: Timestamp converted to the Timezone from which the user is viewing the Site (default PHP/SQL Timezone) + * Local Time: Timestamp converted to the Timezone from which the content (media/post/message) has been sent (Local Timezone stored in timezone field) * * - Feeds (table `feeds`): * - last_update: timestamp in Site Time * - Spot Messages (table `messages`): * - unix_time: UNIX (int) in UTC * - site_time: timestamp in Site Time - * - iso_time: raw ISO 8601 in Local Time + * - iso_time: raw ISO 8601 in UTC or Local Time (spot messages are unreliable, timezone is then calculated from GPS coordinates) + * - posted_on: timestamp in Site Time + * - timezone: Local Timezone * - Medias (table `medias`): * - posted_on: timestamp in Site Time * - taken_on: timestamp in Site Time + * - timezone: Local Timezone * - Posts (table `posts`): * - site_time: timestamp in Site Time + * - timezone: Local Timezone */ class Spot extends Main diff --git a/masks/project.html b/masks/project.html index 4d06f41..bedd556 100644 --- a/masks/project.html +++ b/masks/project.html @@ -992,7 +992,7 @@ function getMediaLink(asData, sType) { .addIcon('fa-upload fa-lg fa-fw', true) .append(asData.posted_on_formatted); - var $TakenOn = (asData.taken_on == '0000-00-00 00:00:00')?'': + var $TakenOn = (asData.taken_on == asData.posted_on)?'': $('', {'class': 'lb-caption-line', title: bTimeDiff?oSpot.lang('local_time', asData.taken_on_formatted_local):''}) .addIcon('fa-'+asData.subtype+'-shot fa-lg fa-fw', true) .append(asData.taken_on_formatted);