2022-05-31 12:30:03 +05:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudApp.Data
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// DTO времени
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class TimeDto
|
|
|
|
|
{
|
|
|
|
|
private int hour = 0;
|
|
|
|
|
private int minute = 0;
|
|
|
|
|
private int second = 0;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// час
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Hour {
|
|
|
|
|
get => hour;
|
|
|
|
|
set {
|
|
|
|
|
if (value > 23 || value < 0)
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(Hour), "hour should be in [0; 23]");
|
|
|
|
|
hour = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// минута
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Minute
|
|
|
|
|
{
|
|
|
|
|
get => minute;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value > 59 || value < 0)
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(minute), "minute should be in [0; 59]");
|
|
|
|
|
minute = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// секунда
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Second
|
|
|
|
|
{
|
|
|
|
|
get => second;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value > 59 || value < 0)
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(second), "second should be in [0; 59]");
|
|
|
|
|
second = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public TimeDto()
|
|
|
|
|
{ }
|
|
|
|
|
|
2022-06-09 13:36:03 +05:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public TimeDto(int hour = 0, int minute = 0, int second = 0)
|
|
|
|
|
{
|
|
|
|
|
this.hour = hour;
|
|
|
|
|
this.minute = minute;
|
|
|
|
|
this.second = second;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-31 12:30:03 +05:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public TimeDto(TimeOnly time)
|
|
|
|
|
{
|
|
|
|
|
hour = time.Hour;
|
|
|
|
|
minute = time.Minute;
|
|
|
|
|
second = time.Second;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Makes System.TimeOnly
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>System.TimeOnly</returns>
|
|
|
|
|
public TimeOnly MakeTimeOnly() => new(Hour, Minute, Second);
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
var str = $"{Hour:00}:{Minute:00}:{Second:00}";
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|