mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 20:36:15 +02:00
Correctly parsing parameters
This commit is contained in:
parent
272eacc1f8
commit
011fa8117d
|
|
@ -46,8 +46,9 @@ class SystemApiController extends BaseApiController
|
|||
public function GetSystemTime(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$offset = 0;
|
||||
if (isset($args['offset']))
|
||||
$offset = $args['offset'];
|
||||
$params = $request->getQueryParams();
|
||||
if (isset($params['offset']))
|
||||
$offset = $params['offset'];
|
||||
return $this->ApiResponse($response, $this->getApplicationService()->GetSystemTime($offset));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class ApplicationService extends BaseService
|
|||
private static function convertToUtc(int $timestamp):string
|
||||
{
|
||||
$timestamp = time();
|
||||
$dt = new DateTime('now', new DateTimeZone('UTC'));
|
||||
$dt = new \DateTime('now', new \DateTimeZone('UTC'));
|
||||
$dt->setTimestamp($timestamp);
|
||||
return $dt->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
|
@ -91,7 +91,7 @@ class ApplicationService extends BaseService
|
|||
*/
|
||||
public function GetSystemTime(int $offset = 0):array
|
||||
{
|
||||
$timestamp = time();
|
||||
$timestamp = time()+$offset;
|
||||
$timeLocal = date('Y-m-d H:i:s', $timestamp);
|
||||
$timeUTC = self::convertToUtc($timestamp);
|
||||
return [
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user