support UnixTime in Units
This commit is contained in:
parent
2738fe5aab
commit
1b9353b1db
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../Utils/Utils.csproj" />
|
||||
<ProjectReference Include="../Time/Time.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
||||
|
|
Loading…
Reference in New Issue