Skip to content

Commit

Permalink
Adjusting Duration initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
alectutin-qut committed Nov 3, 2023
1 parent fb9f892 commit 4b272d2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rcldotnet/Clock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ public enum ClockChange

// Internal as TimeSpan should be user-facing.
[StructLayout(LayoutKind.Sequential)]
internal struct Duration
internal readonly struct Duration
{
public long nanoseconds;
private readonly long _nanoseconds;

public Duration(TimeSpan timeSpan)
{
nanoseconds = (long)(timeSpan.TotalMilliseconds * TimeConstants.NanosecondsPerMillisecond);
_nanoseconds = checked(timeSpan.Ticks * TimeConstants.NanosecondsPerTimespanTick);
}

public TimeSpan AsTimespan()
{
return new TimeSpan(nanoseconds / TimeConstants.NanosecondsPerTimespanTick);
return new TimeSpan(_nanoseconds / TimeConstants.NanosecondsPerTimespanTick);
}
}

Expand Down

0 comments on commit 4b272d2

Please sign in to comment.