diff options
| author | Patrick Barron <18354464+barronpm@users.noreply.github.com> | 2020-07-22 16:18:53 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-22 16:18:53 +0000 |
| commit | 968922e920c97d88fa4fe9194a814a0b03e1a332 (patch) | |
| tree | 50fd6d2954b9ab14817d54314e5a1db48c7eb961 /Jellyfin.Api/Controllers/TimeSyncController.cs | |
| parent | 5b57c81ee14ce585161b9ac331e6e3528826b815 (diff) | |
| parent | 69e6dd2747df84dd732ecf89fea9118085f064ea (diff) | |
Merge pull request #3564 from Ullmie02/api-syncplay
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; + } + } +} |
