Skip to content

Commit 06fc2e0

Browse files
authored
Fix exception with DateTime from ticks (#104)
***PUBLISH_RELEASE*** ***UPDATE_DEPENDENTS***
1 parent 4d7c0a9 commit 06fc2e0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

source/nanoFramework.CoreLibrary/System/DateTime.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,16 @@ private enum DateTimePart
170170
/// <exception cref="System.ArgumentOutOfRangeException"><paramref name="ticks"/> - Ticks must be between <see cref="DateTime.MinValue"/> and <see cref="DateTime.MaxValue"/>.</exception>
171171
public DateTime(long ticks)
172172
{
173-
ticks -= _ticksAtOrigin;
174-
175173
#pragma warning disable S3928 // Parameter names used into ArgumentException constructors should match an existing one
176174
if (ticks < MinTicks || ticks > MaxTicks)
177175
{
178176
throw new ArgumentOutOfRangeException();
179177
}
180178
#pragma warning restore S3928 // Parameter names used into ArgumentException constructors should match an existing one
181179

180+
// need to subtract our ticks at origin
181+
ticks -= _ticksAtOrigin;
182+
182183
_ticks = (ulong)ticks;
183184

184185
// allways UTC

0 commit comments

Comments
 (0)