mirror of
https://github.com/grocy/grocy.git
synced 2026-04-06 21:06: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)
|
public function GetSystemTime(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||||
{
|
{
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
if (isset($args['offset']))
|
$params = $request->getQueryParams();
|
||||||
$offset = $args['offset'];
|
if (isset($params['offset']))
|
||||||
|
$offset = $params['offset'];
|
||||||
return $this->ApiResponse($response, $this->getApplicationService()->GetSystemTime($offset));
|
return $this->ApiResponse($response, $this->getApplicationService()->GetSystemTime($offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ class ApplicationService extends BaseService
|
||||||
private static function convertToUtc(int $timestamp):string
|
private static function convertToUtc(int $timestamp):string
|
||||||
{
|
{
|
||||||
$timestamp = time();
|
$timestamp = time();
|
||||||
$dt = new DateTime('now', new DateTimeZone('UTC'));
|
$dt = new \DateTime('now', new \DateTimeZone('UTC'));
|
||||||
$dt->setTimestamp($timestamp);
|
$dt->setTimestamp($timestamp);
|
||||||
return $dt->format('Y-m-d H:i:s');
|
return $dt->format('Y-m-d H:i:s');
|
||||||
}
|
}
|
||||||
|
|
@ -91,7 +91,7 @@ class ApplicationService extends BaseService
|
||||||
*/
|
*/
|
||||||
public function GetSystemTime(int $offset = 0):array
|
public function GetSystemTime(int $offset = 0):array
|
||||||
{
|
{
|
||||||
$timestamp = time();
|
$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 [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user