mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 20:36:15 +02:00
Added Sqlite3 time to output
This commit is contained in:
parent
5f91b70b32
commit
f74227f738
|
|
@ -5215,6 +5215,10 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "date-time"
|
"format": "date-time"
|
||||||
},
|
},
|
||||||
|
"time_local_sqlite3": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
"time_utc": {
|
"time_utc": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "date-time"
|
"format": "date-time"
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,13 @@ class ApplicationService extends BaseService
|
||||||
return $dt->format('Y-m-d H:i:s');
|
return $dt->format('Y-m-d H:i:s');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static function getSqliteLocaltime(int $offset):string
|
||||||
|
{
|
||||||
|
$pdo = new \PDO('sqlite::memory:');
|
||||||
|
return $pdo->query('SELECT datetime(\'now\', \'+' . $offset . ' seconds\', \'localtime\');')->fetch()[0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the response for the API call /system/time
|
* Returns the response for the API call /system/time
|
||||||
* @param int $offset an offset in seconds to be applied
|
* @param int $offset an offset in seconds to be applied
|
||||||
|
|
@ -90,15 +97,16 @@ class ApplicationService extends BaseService
|
||||||
*/
|
*/
|
||||||
public function GetSystemTime(int $offset = 0):array
|
public function GetSystemTime(int $offset = 0):array
|
||||||
{
|
{
|
||||||
$timestamp = time()+$offset;
|
$timestamp = time() + $offset;
|
||||||
$timeLocal = date('Y-m-d H:i:s', $timestamp);
|
$timeLocal = date('Y-m-d H:i:s', $timestamp);
|
||||||
$timeUTC = self::convertToUtc($timestamp);
|
$timeUTC = self::convertToUtc($timestamp);
|
||||||
return [
|
return [
|
||||||
'timezone' => date_default_timezone_get(),
|
'timezone' => date_default_timezone_get(),
|
||||||
'time_local' => $timeLocal,
|
'time_local' => $timeLocal,
|
||||||
'time_utc' => $timeUTC,
|
'time_local_sqlite3' => self::getSqliteLocaltime($offset),
|
||||||
'timestamp' => $timestamp,
|
'time_utc' => $timeUTC,
|
||||||
'offset' => $offset
|
'timestamp' => $timestamp,
|
||||||
|
'offset' => $offset
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user