Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ TryCreate()

static bool System.DateTime.TryCreate ( int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond,
out DateTime result )
inlinestaticpackage

Definition at line 1365 of file DateTime.cs.

1366 {
1367 result = default(DateTime);
1368 if (year < 1 || year > 9999 || month < 1 || month > 12 || day < 1)
1369 {
1370 return false;
1371 }
1372 if ((uint)hour >= 24u || (uint)minute >= 60u || (uint)millisecond >= 1000u)
1373 {
1374 return false;
1375 }
1377 if ((uint)day > array[month] - array[month - 1])
1378 {
1379 return false;
1380 }
1381 ulong num = (ulong)(uint)((int)(DaysToYear((uint)year) + array[month - 1]) + day - 1) * 864000000000uL;
1382 if ((uint)second < 60u)
1383 {
1384 num += TimeToTicks(hour, minute, second) + (uint)(millisecond * 10000);
1385 }
1386 else
1387 {
1388 if (second != 60 || !s_systemSupportsLeapSeconds || !IsValidTimeWithLeapSeconds(year, month, day, hour, minute, DateTimeKind.Unspecified))
1389 {
1390 return false;
1391 }
1392 num += TimeToTicks(hour, minute, 59) + 9990000;
1393 }
1394 result = new DateTime(num);
1395 return true;
1396 }
static unsafe bool IsValidTimeWithLeapSeconds(int year, int month, int day, int hour, int minute, DateTimeKind kind)
Definition DateTime.cs:1487
static ulong TimeToTicks(int hour, int minute, int second)
Definition DateTime.cs:604
static readonly uint[] s_daysToMonth366
Definition DateTime.cs:29
static bool IsLeapYear(int year)
Definition DateTime.cs:898
static uint DaysToYear(uint year)
Definition DateTime.cs:596
static readonly uint[] s_daysToMonth365
Definition DateTime.cs:23
static readonly bool s_systemSupportsLeapSeconds
Definition DateTime.cs:43

References System.array, System.DateTime, System.DateTime.DaysToYear(), System.Runtime.Serialization.Dictionary, System.DateTime.IsLeapYear(), System.DateTime.IsValidTimeWithLeapSeconds(), System.DateTime.s_daysToMonth365, System.DateTime.s_daysToMonth366, System.DateTime.s_systemSupportsLeapSeconds, System.DateTime.TimeToTicks(), and System.year.

Referenced by System.DateTimeParse.ParseFormatO(), and System.Globalization.GregorianCalendar.TryToDateTime().