Skip to content

Commit

Permalink
#915 span cttor
Browse files Browse the repository at this point in the history
  • Loading branch information
zhabis committed Jun 14, 2024
1 parent c3710df commit 3d4c9c2
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Azos/Time/HourList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,27 @@ public struct HourList : IEquatable<HourList>, IJsonWritable, IJsonReadable, IVa
/// </summary>
public struct Span : IEquatable<Span>, IComparable<Span>
{
private void checkInvariants()
{
(StartMinute <= MINUTES_PER_DAY).IsTrue("start <= MINUTES_PER_DAY");
(DurationMinutes >= 0).IsTrue("dur >= 0");
(StartMinute + DurationMinutes < MINUTES_PER_DAY * 2).IsTrue("finish < 2 days");
}

internal Span(int start, int duration)
public Span(int start, int duration)
{
(start <= MINUTES_PER_DAY).IsTrue("start <= MINUTES_PER_DAY");
(duration >= 0 && duration < MINUTES_PER_DAY * 2).IsTrue("duration >= 0 && < MIN_PER-DAY*2");
StartMinute = start;
DurationMinutes = duration;
checkInvariants();
}

public Span(DateTime start, DateTime end)
{
(start.Kind == end.Kind).IsTrue("sd.kind==ed.kind");
(start <= end).IsTrue("start<=end");
StartMinute = start.Minute;
DurationMinutes = (int)(end - start).TotalMinutes;
checkInvariants();
}

/// <summary>
Expand Down

0 comments on commit 3d4c9c2

Please sign in to comment.