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