DD.WellWorkover.Cloud/AsbCloudApp/Data/SimpleTimezoneDto.cs
2024-08-19 10:01:07 +05:00

50 lines
1.3 KiB
C#

using System;
namespace AsbCloudApp.Data;
/// <summary>
/// временная зона
/// </summary>
public class SimpleTimezoneDto
{
/// <summary>
/// смещение в часах относительно UTC
/// </summary>
public double Hours { get; set; }
/// <summary>
/// идентификатор часовой зоны
/// </summary>
public string? TimezoneId { get; set; }
/// <summary>
/// запрет на переопределение
/// </summary>
public bool IsOverride { get; set; }
/// <summary>
/// Смещение часового пояса
/// </summary>
public TimeSpan Offset => TimeSpan.FromHours(Hours);
/// <inheritdoc/>
public override bool Equals(object? obj)
{
if (obj is SimpleTimezoneDto tTimeZone
&& tTimeZone.Hours == Hours
&& tTimeZone.TimezoneId == TimezoneId
&& tTimeZone.IsOverride == IsOverride)
return true;
return false;
}
/// <inheritdoc/>
public override int GetHashCode()
=> Hours.GetHashCode()
| TimezoneId?.GetHashCode()??-1
| IsOverride.GetHashCode();
/// <inheritdoc/>
public override string ToString()
=> $"{TimezoneId} (UTC+{Hours:00.##})";
}