Skip to content

Commit

Permalink
Move DateTime for Unix to shared partition (dotnet/coreclr#22383)
Browse files Browse the repository at this point in the history
* Move DateTime for Unix to shared partition

* Keep CoreCLR specific implementation

Signed-off-by: dotnet-bot <[email protected]>
  • Loading branch information
marek-safar authored and dotnet-bot committed Feb 8, 2019
1 parent e01e2c8 commit a6d363c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

internal static partial class Interop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.Write.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\IO\File.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\DateTime.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebugProvider.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Environment.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CalendarData.Unix.cs" />
Expand Down
27 changes: 27 additions & 0 deletions src/System.Private.CoreLib/shared/System/DateTime.Unix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System
{
public readonly partial struct DateTime
{
internal const bool s_systemSupportsLeapSeconds = false;

#if !CORECLR
public static DateTime UtcNow
{
get
{
return new DateTime(((ulong)(Interop.Sys.GetSystemTimeAsTicks() + UnixEpochTicks)) | KindUtc);
}
}
#endif

internal static DateTime FromFileTimeLeapSecondsAware(long fileTime) => default;
internal static long ToFileTimeLeapSecondsAware(long ticks) => default;

// IsValidTimeWithLeapSeconds is not expected to be called at all for now on non-Windows platforms
internal static bool IsValidTimeWithLeapSeconds(int year, int month, int day, int hour, int minute, int second, DateTimeKind kind) => false;
}
}

0 comments on commit a6d363c

Please sign in to comment.