Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ ToString() [4/4]

string System.DateOnly.ToString ( string? format,
IFormatProvider? provider )
inline

Implements System.IFormattable.

Definition at line 479 of file DateOnly.cs.

480 {
481 if (format == null || format.Length == 0)
482 {
483 format = "d";
484 }
485 if (format.Length == 1)
486 {
487 switch (format[0])
488 {
489 case 'O':
490 case 'o':
491 return string.Create(10, this, delegate(Span<char> destination, DateOnly value)
492 {
493 bool flag = DateTimeFormat.TryFormatDateOnlyO(value.Year, value.Month, value.Day, destination);
494 });
495 case 'R':
496 case 'r':
497 return string.Create(16, this, delegate(Span<char> destination, DateOnly value)
498 {
499 bool flag2 = DateTimeFormat.TryFormatDateOnlyR(value.DayOfWeek, value.Year, value.Month, value.Day, destination);
500 });
501 case 'D':
502 case 'M':
503 case 'Y':
504 case 'd':
505 case 'm':
506 case 'y':
507 return DateTimeFormat.Format(GetEquivalentDateTime(), format, provider);
508 default:
509 throw new FormatException(SR.Format_InvalidString);
510 }
511 }
512 DateTimeFormat.IsValidCustomDateFormat(format.AsSpan(), throwOnError: true);
513 return DateTimeFormat.Format(GetEquivalentDateTime(), format, provider);
514 }
DateTime GetEquivalentDateTime()
Definition DateOnly.cs:38
DateOnly(int dayNumber)
Definition DateOnly.cs:43

References System.destination, System.DateTimeFormat.Format(), System.format, System.SR.Format_InvalidString, System.DateOnly.GetEquivalentDateTime(), System.DateTimeFormat.IsValidCustomDateFormat(), System.DateTimeFormat.TryFormatDateOnlyO(), System.DateTimeFormat.TryFormatDateOnlyR(), and System.value.