mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-01-13 17:22:54 -05:00
Add timezone to national days API
This commit is contained in:
@@ -9,10 +9,14 @@ namespace ChrisKaczor.HomeMonitor.Calendar.Service.Controllers;
|
||||
public class NationalDaysController(IConfiguration configuration, RestClient restClient) : ControllerBase
|
||||
{
|
||||
[HttpGet("today")]
|
||||
public async Task<ActionResult<Response>> GetToday()
|
||||
public async Task<ActionResult<Response>> GetToday([FromQuery] string timezone = "Etc/UTC")
|
||||
{
|
||||
var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timezone);
|
||||
var timeZoneOffset = timeZoneInfo.GetUtcOffset(DateTimeOffset.Now).TotalHours;
|
||||
|
||||
var restRequest = new RestRequest(configuration["Calendar:NationalDays:Url"]);
|
||||
restRequest.AddHeader("X-Api-Key", configuration["Calendar:NationalDays:Key"] ?? string.Empty);
|
||||
restRequest.AddQueryParameter("timezone_offset", timeZoneOffset);
|
||||
|
||||
var response = await restClient.GetAsync<Response>(restRequest);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user