|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | 3 | // See the LICENSE file in the project root for more information. |
4 | 4 |
|
| 5 | +using System; |
| 6 | +using System.Threading; |
| 7 | +using System.Globalization; |
| 8 | +using System.Runtime; |
| 9 | +using System.Runtime.InteropServices; |
| 10 | +using System.Runtime.CompilerServices; |
| 11 | +using System.Runtime.Serialization; |
| 12 | +using System.Runtime.Versioning; |
| 13 | +using System.Security; |
| 14 | +using System.Diagnostics.Contracts; |
| 15 | +using CultureInfo = System.Globalization.CultureInfo; |
| 16 | +using Calendar = System.Globalization.Calendar; |
| 17 | + |
5 | 18 | namespace System |
6 | 19 | { |
7 | | - using System; |
8 | | - using System.Threading; |
9 | | - using System.Globalization; |
10 | | - using System.Runtime; |
11 | | - using System.Runtime.InteropServices; |
12 | | - using System.Runtime.CompilerServices; |
13 | | - using System.Runtime.Serialization; |
14 | | - using System.Runtime.Versioning; |
15 | | - using System.Security; |
16 | | - using System.Diagnostics.Contracts; |
17 | | - using CultureInfo = System.Globalization.CultureInfo; |
18 | | - using Calendar = System.Globalization.Calendar; |
19 | 20 |
|
20 | 21 | // This value type represents a date and time. Every DateTime |
21 | 22 | // object has a private field (Ticks) of type Int64 that stores the |
@@ -52,7 +53,7 @@ namespace System |
52 | 53 | // |
53 | 54 | [StructLayout(LayoutKind.Auto)] |
54 | 55 | [Serializable] |
55 | | - public struct DateTime : IComparable, IFormattable, IConvertible, IComparable<DateTime>, IEquatable<DateTime>, ISerializable |
| 56 | + public partial struct DateTime : IComparable, IFormattable, IConvertible, IComparable<DateTime>, IEquatable<DateTime>, ISerializable |
56 | 57 | { |
57 | 58 | // Number of 100ns ticks per time unit |
58 | 59 | private const long TicksPerMillisecond = 10000; |
@@ -89,6 +90,7 @@ public struct DateTime : IComparable, IFormattable, IConvertible, IComparable<Da |
89 | 90 | internal const long MaxTicks = DaysTo10000 * TicksPerDay - 1; |
90 | 91 | private const long MaxMillis = (long)DaysTo10000 * MillisPerDay; |
91 | 92 |
|
| 93 | + private const long TicksTo1970 = DaysTo1970 * TicksPerDay; |
92 | 94 | private const long FileTimeOffset = DaysTo1601 * TicksPerDay; |
93 | 95 | private const long DoubleDateOffset = DaysTo1899 * TicksPerDay; |
94 | 96 | // The minimum OA date is 0100/01/01 (Note it's year 100). |
@@ -1005,25 +1007,6 @@ public static DateTime Now |
1005 | 1007 | } |
1006 | 1008 | } |
1007 | 1009 |
|
1008 | | - public static DateTime UtcNow |
1009 | | - { |
1010 | | - get |
1011 | | - { |
1012 | | - Contract.Ensures(Contract.Result<DateTime>().Kind == DateTimeKind.Utc); |
1013 | | - // following code is tuned for speed. Don't change it without running benchmark. |
1014 | | - long ticks = 0; |
1015 | | - ticks = GetSystemTimeAsFileTime(); |
1016 | | - |
1017 | | - return new DateTime(((UInt64)(ticks + FileTimeOffset)) | KindUtc); |
1018 | | - } |
1019 | | - } |
1020 | | - |
1021 | | - |
1022 | | - [MethodImplAttribute(MethodImplOptions.InternalCall)] |
1023 | | - internal static extern long GetSystemTimeAsFileTime(); |
1024 | | - |
1025 | | - |
1026 | | - |
1027 | 1010 | // Returns the second part of this DateTime. The returned value is |
1028 | 1011 | // an integer between 0 and 59. |
1029 | 1012 | // |
|
0 commit comments