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

◆ TryCreateDateTime()

static bool System.Buffers.Text.Utf8Parser.TryCreateDateTime ( int year,
int month,
int day,
int hour,
int minute,
int second,
int fraction,
DateTimeKind kind,
out DateTime value )
inlinestaticprivate

Definition at line 525 of file Utf8Parser.cs.

526 {
527 if (year == 0)
528 {
529 value = default(DateTime);
530 return false;
531 }
532 if ((uint)(month - 1) >= 12u)
533 {
534 value = default(DateTime);
535 return false;
536 }
537 uint num = (uint)(day - 1);
538 if (num >= 28 && num >= DateTime.DaysInMonth(year, month))
539 {
540 value = default(DateTime);
541 return false;
542 }
543 if ((uint)hour > 23u)
544 {
545 value = default(DateTime);
546 return false;
547 }
548 if ((uint)minute > 59u)
549 {
550 value = default(DateTime);
551 return false;
552 }
553 if ((uint)second > 59u)
554 {
555 value = default(DateTime);
556 return false;
557 }
558 int[] array = (DateTime.IsLeapYear(year) ? s_daysToMonth366 : s_daysToMonth365);
559 int num2 = year - 1;
560 int num3 = num2 * 365 + num2 / 4 - num2 / 100 + num2 / 400 + array[month - 1] + day - 1;
561 long num4 = num3 * 864000000000L;
562 int num5 = hour * 3600 + minute * 60 + second;
563 num4 += (long)num5 * 10000000L;
564 num4 += fraction;
565 value = new DateTime(num4, kind);
566 return true;
567 }
static readonly int[] s_daysToMonth366
static readonly int[] s_daysToMonth365

References System.array, System.DateTime, System.DateTime.DaysInMonth(), System.DateTime.IsLeapYear(), System.L, System.Buffers.Text.Utf8Parser.s_daysToMonth365, System.Buffers.Text.Utf8Parser.s_daysToMonth366, System.value, and System.year.

Referenced by System.Buffers.Text.Utf8Parser.TryCreateDateTimeOffset(), and System.Buffers.Text.Utf8Parser.TryCreateDateTimeOffsetInterpretingDataAsLocalTime().