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

51 lines
1.4 KiB
C#
Raw Normal View History

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