laatzen/Common/CommonMessurementUnits/Time.cs
2023-09-14 13:04:12 +02:00

47 lines
1.1 KiB
C#

using System;
using Newtonsoft.Json;
using Xylem.Common.CommonCore.CommonMeasurementUnits.JsonConverters;
namespace Xylem.Common.CommonCore.CommonMeasurementUnits
{
[JsonConverter(typeof(TimeConverter))]
public class Time : Unit
{
public Double Miliseconds
{
get => Seconds * MsInSec;
set => Seconds = value / MsInSec;
}
public Double Seconds
{
get => value;
set => this.value = value;
}
public Double Minutes
{
get => Seconds / SecInMin;
set => Seconds = value * SecInMin;
}
public Double Hours
{
get => Minutes / MinInH;
set => Minutes = value * MinInH;
}
public Double Days
{
get => Hours / HInDay;
set => Hours = value * HInDay;
}
public static implicit operator Time(Double x)
=> new Time { value = x };
public static implicit operator Time(Double? x)
=> new Time { value = x ?? 0 };
}
}