From 2285e290ff922ee636bb797c087c3167fa936dc7 Mon Sep 17 00:00:00 2001 From: Marc Ole Bulling Date: Mon, 28 Dec 2020 11:58:45 +0100 Subject: [PATCH] Fixed implimentation, added to openapi.json --- grocy.openapi.json | 66 +++++++++++++++++++++++++++++++++ services/ApplicationService.php | 1 - 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/grocy.openapi.json b/grocy.openapi.json index 2e231ede..784b4c90 100644 --- a/grocy.openapi.json +++ b/grocy.openapi.json @@ -146,6 +146,41 @@ } } }, + "/system/time": { + "get": { + "summary": "Returns the current server time", + "tags": [ + "System" + ], + "parameters": [ + { + "$ref": "#/components/parameters/offsettime" + } + ], + "responses": { + "200": { + "description": "A TimeResponse object", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TimeResponse" + } + } + } + }, + "400": { + "description": "The operation was not successful", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error400" + } + } + } + } + } + } + }, "/system/log-missing-localization": { "post": { "summary": "Logs a missing localization string", @@ -5170,6 +5205,28 @@ } } }, + "TimeResponse": { + "type": "object", + "properties": { + "timezone": { + "type": "string" + }, + "time_local": { + "type": "string", + "format": "date-time" + }, + "time_utc": { + "type": "string", + "format": "date-time" + }, + "timestamp": { + "type": "integer" + }, + "offset": { + "type": "integer" + } + } + }, "UserSetting": { "type": "object", "properties": { @@ -5222,6 +5279,15 @@ "type": "integer" } }, + "offsettime": { + "in": "query", + "name": "offset", + "required": false, + "description": "Offset of timestamp in seconds. Can be positive or negative.", + "schema": { + "type": "integer" + } + }, "query": { "in": "query", "name": "query[]", diff --git a/services/ApplicationService.php b/services/ApplicationService.php index 3b60a630..9eef3070 100644 --- a/services/ApplicationService.php +++ b/services/ApplicationService.php @@ -78,7 +78,6 @@ class ApplicationService extends BaseService private static function convertToUtc(int $timestamp):string { - $timestamp = time(); $dt = new \DateTime('now', new \DateTimeZone('UTC')); $dt->setTimestamp($timestamp); return $dt->format('Y-m-d H:i:s');