Innovenergy_trunk/csharp/lib/Time/Unix/UnixTimeDelta.Constructors.cs

26 lines
1.1 KiB
C#

namespace InnovEnergy.Time.Unix;
public readonly partial struct UnixTimeSpan
{
private UnixTimeSpan(UInt32 ticks) => Ticks = ticks;
public static UnixTimeSpan FromTicks(UInt32 ticks) => new UnixTimeSpan(ticks);
public static UnixTimeSpan FromTimeSpan(TimeSpan timeSpan)
{
var ticks = (UInt32) timeSpan.TotalSeconds;
return FromTicks(ticks);
}
public static UnixTimeSpan FromSeconds(UInt32 s) => FromTicks (s);
public static UnixTimeSpan FromMinutes(UInt32 m) => FromSeconds(m * 60);
public static UnixTimeSpan FromHours (UInt32 h) => FromMinutes(h * 60);
public static UnixTimeSpan FromDays (UInt32 d) => FromHours (d * 24);
public static UnixTimeSpan FromWeeks (UInt32 w) => FromDays (w * 7);
public static UnixTimeSpan FromSeconds(Int32 s) => FromSeconds((UInt32) s);
public static UnixTimeSpan FromMinutes(Int32 m) => FromMinutes((UInt32) m);
public static UnixTimeSpan FromHours (Int32 h) => FromHours ((UInt32) h);
public static UnixTimeSpan FromDays (Int32 d) => FromDays ((UInt32) d);
public static UnixTimeSpan FromWeeks (Int32 w) => FromWeeks ((UInt32) w);
}