47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
namespace CommonMessurementUnits
|
|
{
|
|
using CommonMessurementUnits.JsonConverters;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
[JsonConverter(typeof(TimeConverter))]
|
|
public class Time : Base
|
|
{
|
|
public double Miliseconds
|
|
{
|
|
get => this.Seconds * MsInSec;
|
|
set => this.Seconds = value / MsInSec;
|
|
}
|
|
|
|
public double Seconds
|
|
{
|
|
get => this.value;
|
|
set => this.value = value;
|
|
}
|
|
|
|
public double Minutes
|
|
{
|
|
get => this.Seconds / SecInMin;
|
|
set => this.Seconds = value * SecInMin;
|
|
}
|
|
|
|
public double Hours
|
|
{
|
|
get => this.Minutes / MinInH;
|
|
set => this.Minutes = value * MinInH;
|
|
}
|
|
|
|
public double Days
|
|
{
|
|
get => this.Hours / HInDay;
|
|
set => this.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 };
|
|
}
|
|
}
|