This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move TimeZoneInfo.Win32.cs to shared CoreLib partition (#15953)
Reconcile deltas with CoreRT and refactor interop to follow coding conventions Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
- Loading branch information
1 parent
c955510
commit 946e04b
Showing
5 changed files
with
1,146 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/Common/src/CoreLib/Interop/Windows/Kernel32/Interop.MUI.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// 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. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class Kernel32 | ||
{ | ||
internal const uint MUI_PREFERRED_UI_LANGUAGES = 0x10; | ||
|
||
[DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] | ||
internal static extern bool GetFileMUIPath(uint flags, String filePath, [Out] StringBuilder language, ref int languageLength, [Out] StringBuilder fileMuiPath, ref int fileMuiPathLength, ref Int64 enumerator); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/Common/src/CoreLib/Interop/Windows/Kernel32/Interop.TimeZone.Registry.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// 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. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class Kernel32 | ||
{ | ||
[StructLayout(LayoutKind.Sequential)] | ||
internal struct REG_TZI_FORMAT | ||
{ | ||
internal int Bias; | ||
internal int StandardBias; | ||
internal int DaylightBias; | ||
internal SYSTEMTIME StandardDate; | ||
internal SYSTEMTIME DaylightDate; | ||
|
||
internal REG_TZI_FORMAT(in TIME_ZONE_INFORMATION tzi) | ||
{ | ||
Bias = tzi.Bias; | ||
StandardDate = tzi.StandardDate; | ||
StandardBias = tzi.StandardBias; | ||
DaylightDate = tzi.DaylightDate; | ||
DaylightBias = tzi.DaylightBias; | ||
} | ||
} | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
src/Common/src/CoreLib/Interop/Windows/Kernel32/Interop.TimeZone.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// 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. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class Kernel32 | ||
{ | ||
internal struct SYSTEMTIME | ||
{ | ||
internal ushort Year; | ||
internal ushort Month; | ||
internal ushort DayOfWeek; | ||
internal ushort Day; | ||
internal ushort Hour; | ||
internal ushort Minute; | ||
internal ushort Second; | ||
internal ushort Milliseconds; | ||
|
||
internal bool Equals(in SYSTEMTIME other) => | ||
Year == other.Year && | ||
Month == other.Month && | ||
DayOfWeek == other.DayOfWeek && | ||
Day == other.Day && | ||
Hour == other.Hour && | ||
Minute == other.Minute && | ||
Second == other.Second && | ||
Milliseconds == other.Milliseconds; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] | ||
internal unsafe struct TIME_DYNAMIC_ZONE_INFORMATION | ||
{ | ||
internal int Bias; | ||
internal fixed char StandardName[32]; | ||
internal SYSTEMTIME StandardDate; | ||
internal int StandardBias; | ||
internal fixed char DaylightName[32]; | ||
internal SYSTEMTIME DaylightDate; | ||
internal int DaylightBias; | ||
internal fixed char TimeZoneKeyName[128]; | ||
internal byte DynamicDaylightTimeDisabled; | ||
|
||
internal string GetTimeZoneKeyName() | ||
{ | ||
fixed (char* p = TimeZoneKeyName) | ||
return new string(p); | ||
} | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] | ||
internal unsafe struct TIME_ZONE_INFORMATION | ||
{ | ||
internal int Bias; | ||
internal fixed char StandardName[32]; | ||
internal SYSTEMTIME StandardDate; | ||
internal int StandardBias; | ||
internal fixed char DaylightName[32]; | ||
internal SYSTEMTIME DaylightDate; | ||
internal int DaylightBias; | ||
|
||
internal TIME_ZONE_INFORMATION(in TIME_DYNAMIC_ZONE_INFORMATION dtzi) | ||
{ | ||
// The start of TIME_DYNAMIC_ZONE_INFORMATION has identical layout as TIME_ZONE_INFORMATION | ||
fixed (TIME_ZONE_INFORMATION* pTo = &this) | ||
fixed (TIME_DYNAMIC_ZONE_INFORMATION* pFrom = &dtzi) | ||
*pTo = *(TIME_ZONE_INFORMATION*)pFrom; | ||
} | ||
|
||
internal string GetStandardName() | ||
{ | ||
fixed (char* p = StandardName) | ||
return new string(p); | ||
} | ||
|
||
internal string GetDaylightName() | ||
{ | ||
fixed (char* p = DaylightName) | ||
return new string(p); | ||
} | ||
} | ||
|
||
internal const uint TIME_ZONE_ID_INVALID = unchecked((uint)-1); | ||
|
||
[DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] | ||
internal extern static uint GetDynamicTimeZoneInformation(out TIME_DYNAMIC_ZONE_INFORMATION pTimeZoneInformation); | ||
|
||
[DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] | ||
internal static extern uint GetTimeZoneInformation(out TIME_ZONE_INFORMATION lpTimeZoneInformation); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.