DD.WellWorkover.Cloud/AsbCloudApp/Data/SimpleTimezoneDto.cs

50 lines
1.3 KiB
C#
Raw Permalink Normal View History

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