Innovenergy_trunk/csharp/Lib/Units/Energy.cs

16 lines
555 B
C#
Raw Normal View History

2023-03-08 13:17:39 +00:00
using InnovEnergy.Lib.Time.Unix;
2023-03-08 13:06:39 +00:00
using InnovEnergy.Lib.Units.Generator;
namespace InnovEnergy.Lib.Units;
[Generate]
2023-03-08 13:06:39 +00:00
public readonly partial struct Energy
{
public static String Unit => "kWh";
public static String Symbol => "E";
public Energy(Decimal value) => Value = value;
2023-03-08 13:17:39 +00:00
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;
2023-03-08 13:06:39 +00:00
}