diff --git a/common/ASC.Common/Utils/TimeZoneConverter/TimeZoneConverter.cs b/common/ASC.Common/Utils/TimeZoneConverter/TimeZoneConverter.cs index c8c549b57b6..7a258451c6e 100644 --- a/common/ASC.Common/Utils/TimeZoneConverter/TimeZoneConverter.cs +++ b/common/ASC.Common/Utils/TimeZoneConverter/TimeZoneConverter.cs @@ -66,6 +66,18 @@ public string GetTimeZoneDisplayName(TimeZoneInfo tz) return displayName; } + public string GetIanaTimeZoneId(TimeZoneInfo timeZone) + { + if (timeZone.HasIanaId) + { + return timeZone.Id; + } + + return TimeZoneInfo.TryConvertWindowsIdToIanaId(timeZone.Id, out var ianaTimeZoneId) + ? ianaTimeZoneId + : WindowsTzId2OlsonTzId(timeZone.Id); + } + public string OlsonTzId2WindowsTzId(string olsonTimeZoneId, bool defaultIfNoMatch = true) { var mapZone = GetMapZoneByWindowsTzId(olsonTimeZoneId); diff --git a/web/ASC.Web.Api/Api/Settings/SettingsController.cs b/web/ASC.Web.Api/Api/Settings/SettingsController.cs index 06a31322afe..1a576831c3c 100644 --- a/web/ASC.Web.Api/Api/Settings/SettingsController.cs +++ b/web/ASC.Web.Api/Api/Settings/SettingsController.cs @@ -183,9 +183,9 @@ public async Task GetSettingsAsync(bool? withpassword) { settings.TrustedDomains = tenant.TrustedDomains; settings.TrustedDomainsType = tenant.TrustedDomainsType; - var timeZone = tenant.TimeZone; - settings.Timezone = _timeZoneConverter.WindowsTzId2OlsonTzId(timeZone); - settings.UtcOffset = _timeZoneConverter.GetTimeZone(timeZone).GetUtcOffset(DateTime.UtcNow); + var timeZone = _timeZoneConverter.GetTimeZone(tenant.TimeZone); + settings.Timezone = _timeZoneConverter.GetIanaTimeZoneId(timeZone); + settings.UtcOffset = timeZone.GetUtcOffset(DateTime.UtcNow); settings.UtcHoursOffset = settings.UtcOffset.TotalHours; settings.OwnerId = tenant.OwnerId; settings.NameSchemaId = _customNamingPeople.Current.Id; @@ -407,7 +407,7 @@ public async Task> GetTimeZonesAsyncAsync() { listOfTimezones.Add(new TimezonesRequestsDto { - Id = _timeZoneConverter.WindowsTzId2OlsonTzId(tz.Id), + Id = _timeZoneConverter.GetIanaTimeZoneId(tz), DisplayName = _timeZoneConverter.GetTimeZoneDisplayName(tz) }); }