diff --git a/csharp/Lib/Time/Unix/UnixTimeSpan.Operators.cs b/csharp/Lib/Time/Unix/UnixTimeSpan.Operators.cs index dc2805e2d..e59d3dfba 100644 --- a/csharp/Lib/Time/Unix/UnixTimeSpan.Operators.cs +++ b/csharp/Lib/Time/Unix/UnixTimeSpan.Operators.cs @@ -20,7 +20,7 @@ public readonly partial struct UnixTimeSpan public static UnixTimeSpan operator /(UnixTimeSpan a, UInt32 b) => new UnixTimeSpan(a.Ticks / b); public static UnixTimeSpan operator /(UnixTimeSpan a, Int32 b) => new UnixTimeSpan(a.Ticks / (UInt32)b); - public static UInt32 operator /(UnixTimeSpan a, UnixTimeSpan b) => a.Ticks / b.Ticks; + public static UInt32 operator /(UnixTimeSpan a, UnixTimeSpan b) => a.Ticks / b.Ticks; public static UnixTimeSpan operator %(UnixTimeSpan a, UInt32 b) => new UnixTimeSpan(a.Ticks % b); public static UnixTimeSpan operator %(UnixTimeSpan a, Int32 b) => new UnixTimeSpan(a.Ticks % (UInt32)b); diff --git a/csharp/Lib/Units/Energy.cs b/csharp/Lib/Units/Energy.cs index 0f50ba858..006568b06 100644 --- a/csharp/Lib/Units/Energy.cs +++ b/csharp/Lib/Units/Energy.cs @@ -1,3 +1,4 @@ +using InnovEnergy.Lib.Time.Unix; using InnovEnergy.Lib.Units.Generator; @@ -11,5 +12,6 @@ public readonly partial struct Energy public Energy(Decimal value) => Value = value; - public static Power operator /(Energy energy, TimeSpan timeSpan) => energy.Value / (Decimal) timeSpan.TotalHours * 1000m; + 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; } \ No newline at end of file diff --git a/csharp/Lib/Units/Power.cs b/csharp/Lib/Units/Power.cs index eb58ffeb3..de4a7f9ab 100644 --- a/csharp/Lib/Units/Power.cs +++ b/csharp/Lib/Units/Power.cs @@ -1,4 +1,5 @@ +using InnovEnergy.Lib.Time.Unix; using InnovEnergy.Lib.Units.Generator; namespace InnovEnergy.Lib.Units; @@ -17,4 +18,7 @@ public readonly partial struct Power public static Energy operator *(Power power, TimeSpan timeSpan) => power.Value / 1000m * (Decimal) timeSpan.TotalHours; public static Energy operator *(TimeSpan timeSpan, Power power) => power.Value / 1000m * (Decimal) timeSpan.TotalHours; + + public static Energy operator *(Power power, UnixTimeSpan timeSpan) => power.Value * timeSpan.Ticks / 3_600_000; + public static Energy operator *(UnixTimeSpan timeSpan, Power power) => power.Value * timeSpan.Ticks / 3_600_000; } \ No newline at end of file diff --git a/csharp/Lib/Units/Units.csproj b/csharp/Lib/Units/Units.csproj index f750ccf47..422120d58 100644 --- a/csharp/Lib/Units/Units.csproj +++ b/csharp/Lib/Units/Units.csproj @@ -7,6 +7,7 @@ +