// PropertyName should be a valid time string. This is made sure by the IsValid property. // It can also be empty or ISO. In this case, we default to sortable date times: // https://docs.microsoft.com/en-us/dotnet/api/system.globalization.datetimeformatinfo.sortabledatetimepattern private string FormatMetadataInternal(FileMetadata metadata) { if (string.IsNullOrWhiteSpace(PropertyName) || PropertyName.ToUpperInvariant() == "ISO") { // SortableDateTimePattern is the same for all cultures. We can use the invariant culture. return(metadata.Timestamp.ToString(DateTimeFormatInfo.InvariantInfo.SortableDateTimePattern)); } return(metadata.Timestamp.ToString(PropertyName)); }