@@ -303,52 +303,12 @@ public override int GetHashCode()
303303 /// If the DateTimeKind is Unspecified, it's assumed that the underlying
304304 /// Value already represents the system's datetime.
305305 /// </summary>
306- public DateTime AsSystemLocal
307- {
308- get
309- {
310- if ( Value . Kind == DateTimeKind . Unspecified )
311- {
312- return HasTime
313- ? Value
314- : Value . Date ;
315- }
316-
317- return HasTime
318- ? Value . ToLocalTime ( )
319- : Value . ToLocalTime ( ) . Date ;
320- }
321- }
306+ public DateTime AsSystemLocal => AsDateTimeOffset . LocalDateTime ;
322307
323308 /// <summary>
324309 /// Returns a representation of the <see cref="DateTime"/> in UTC.
325310 /// </summary>
326- public DateTime AsUtc
327- {
328- get
329- {
330- // In order of weighting:
331- // 1) Specified TzId
332- // 2) Value having a DateTimeKind.Utc
333- // 3) Use the OS's time zone
334- DateTime asUtc ;
335-
336- if ( ! string . IsNullOrWhiteSpace ( TzId ) )
337- {
338- var asLocal = DateUtil . ToZonedDateTimeLeniently ( Value , TzId ) ;
339- return asLocal . ToDateTimeUtc ( ) ;
340- }
341-
342- if ( IsUtc || Value . Kind == DateTimeKind . Utc )
343- {
344- asUtc = DateTime . SpecifyKind ( Value , DateTimeKind . Utc ) ;
345- return asUtc ;
346- }
347-
348- asUtc = DateTime . SpecifyKind ( Value , DateTimeKind . Local ) . ToUniversalTime ( ) ;
349- return asUtc ;
350- }
351- }
311+ public DateTime AsUtc => AsDateTimeOffset . UtcDateTime ;
352312
353313 /// <summary>
354314 /// Gets the underlying <see cref="DateOnlyValue"/> of <see cref="Value"/>.
@@ -533,7 +493,7 @@ public IDateTime ToTimeZone(string? tzId)
533493 /// </summary>
534494 public DateTimeOffset AsDateTimeOffset =>
535495 string . IsNullOrWhiteSpace ( TzId )
536- ? new DateTimeOffset ( AsSystemLocal )
496+ ? new DateTimeOffset ( Value )
537497 : DateUtil . ToZonedDateTimeLeniently ( Value , TzId ) . ToDateTimeOffset ( ) ;
538498
539499 /// <inheritdoc cref="DateTime.Add"/>
0 commit comments