diff options
| author | David <daullmer@gmail.com> | 2020-07-15 16:15:17 +0200 |
|---|---|---|
| committer | David <daullmer@gmail.com> | 2020-07-15 16:15:17 +0200 |
| commit | 9a2bcd6266fb222491abe6ea31d5e7e734699d5f (patch) | |
| tree | e9182ef0dd6e31b288cb48d83d487cee83685d9c /Jellyfin.Api/Controllers/TimeSyncController.cs | |
| parent | f7c7b1e7e15678bb8ba92f082b9bc2882c87baae (diff) | |
Move SyncPlay api to Jellyfin.Api
Diffstat (limited to 'Jellyfin.Api/Controllers/TimeSyncController.cs')
| -rw-r--r-- | Jellyfin.Api/Controllers/TimeSyncController.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Jellyfin.Api/Controllers/TimeSyncController.cs b/Jellyfin.Api/Controllers/TimeSyncController.cs new file mode 100644 index 000000000..57a720b26 --- /dev/null +++ b/Jellyfin.Api/Controllers/TimeSyncController.cs @@ -0,0 +1,39 @@ +using System; +using System.Globalization; +using MediaBrowser.Model.SyncPlay; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace Jellyfin.Api.Controllers +{ + /// <summary> + /// The time sync controller. + /// </summary> + [Route("/GetUtcTime")] + public class TimeSyncController : BaseJellyfinApiController + { + /// <summary> + /// Gets the current utc time. + /// </summary> + /// <response code="200">Time returned.</response> + /// <returns>An <see cref="UtcTimeResponse"/> to sync the client and server time.</returns> + [HttpGet] + [ProducesResponseType(statusCode: StatusCodes.Status200OK)] + public ActionResult<UtcTimeResponse> GetUtcTime() + { + // Important to keep the following line at the beginning + var requestReceptionTime = DateTime.UtcNow.ToUniversalTime().ToString("o", DateTimeFormatInfo.InvariantInfo); + + var response = new UtcTimeResponse(); + response.RequestReceptionTime = requestReceptionTime; + + // Important to keep the following two lines at the end + var responseTransmissionTime = DateTime.UtcNow.ToUniversalTime().ToString("o", DateTimeFormatInfo.InvariantInfo); + response.ResponseTransmissionTime = responseTransmissionTime; + + // Implementing NTP on such a high level results in this useless + // information being sent. On the other hand it enables future additions. + return response; + } + } +} |
