Innovenergy_trunk/csharp/Lib/Units/Energy.cs

16 lines
555 B
C#

using InnovEnergy.Lib.Time.Unix;
using InnovEnergy.Lib.Units.Generator;
namespace InnovEnergy.Lib.Units;
[Generate]
public readonly partial struct Energy
{
public static String Unit => "kWh";
public static String Symbol => "E";
public Energy(Decimal value) => Value = value;
public static Power operator /(Energy energy, TimeSpan timeSpan) => energy.Value * 1000m / (Decimal) timeSpan.TotalHours ;
public static Power operator /(Energy energy, UnixTimeSpan timeSpan) => energy.Value * 3_600_000m / timeSpan.Ticks;
}