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

◆ ToString() [4/4]

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

Implements System.IFormattable.

Definition at line 530 of file TimeOnly.cs.

531 {
532 if (format == null || format.Length == 0)
533 {
534 format = "t";
535 }
536 if (format.Length == 1)
537 {
538 switch (format[0])
539 {
540 case 'O':
541 case 'o':
542 return string.Create(16, this, delegate(Span<char> destination, TimeOnly value)
543 {
544 bool flag = DateTimeFormat.TryFormatTimeOnlyO(value.Hour, value.Minute, value.Second, value._ticks % 10000000, destination);
545 });
546 case 'R':
547 case 'r':
548 return string.Create(8, this, delegate(Span<char> destination, TimeOnly value)
549 {
550 bool flag2 = DateTimeFormat.TryFormatTimeOnlyR(value.Hour, value.Minute, value.Second, destination);
551 });
552 case 'T':
553 case 't':
554 return DateTimeFormat.Format(ToDateTime(), format, provider);
555 default:
556 throw new FormatException(SR.Format_InvalidString);
557 }
558 }
559 DateTimeFormat.IsValidCustomTimeFormat(format.AsSpan(), throwOnError: true);
560 return DateTimeFormat.Format(ToDateTime(), format, provider);
561 }
TimeOnly(int hour, int minute)
Definition TimeOnly.cs:31
DateTime ToDateTime()
Definition TimeOnly.cs:181

References System.destination, System.DateTimeFormat.Format(), System.format, System.SR.Format_InvalidString, System.DateTimeFormat.IsValidCustomTimeFormat(), System.TimeOnly.ToDateTime(), System.DateTimeFormat.TryFormatTimeOnlyO(), System.DateTimeFormat.TryFormatTimeOnlyR(), and System.value.