blob: 68d4583b54a20d6a568e040ebe773408649af16d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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 static extern 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);
}
}
|