Merge pull request #1144 from CHTJonas/master

Use UTC timestamps for CAT control
这个提交包含在:
Peter Goodhall 2021-08-31 21:52:40 +01:00 提交者 GitHub
当前提交 c67e0a92e6
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有 3 个文件被更改,包括 14 次插入5 次删除

查看文件

@ -455,14 +455,18 @@ class API extends CI_Controller {
}
/* ENDPOINT for Rig Control */
/*
* ENDPOINT for Rig Control
*
* Note: timestamp should always be in UTC
*/
function radio() {
header('Content-type: application/json');
$this->load->model('api_model');
//$json = '{"radio":"FT-950","frequency":14075,"mode":"SSB","timestamp":"2012/04/07 16:47"}';
//$json = '{"radio":"FT-950","frequency":14075,"mode":"SSB","timestamp":"2012/04/07 16:47:31"}';
$this->load->model('cat');
@ -476,6 +480,10 @@ class API extends CI_Controller {
die();
}
if(!isset($obj['timestamp'])) {
$obj['timestamp'] = gmdate('Y/m/d H:i:s'); // in UTC
}
// Store Result to Database
$this->cat->update($obj);

查看文件

@ -120,8 +120,9 @@
}
// Calculate how old the data is in minutes
$datetime1 = new DateTime(); // Today's Date/Time
$datetime2 = new DateTime($row->newtime);
$timezone = new DateTimeZone("UTC");
$datetime1 = new DateTime("now", $timezone);
$datetime2 = new DateTime($row->timestamp, $timezone);
$interval = $datetime1->diff($datetime2);
$minutes = $interval->days * 24 * 60;

查看文件

@ -102,7 +102,7 @@
function radio_status($id) {
return $this->db->query('SELECT *, CONVERT_TZ(`timestamp`, @@session.time_zone, \'+00:00\' ) as newtime FROM `cat` WHERE id = '.$id.' ');
return $this->db->query('SELECT * FROM `cat` WHERE id = '.$id.' ');
}