using NodaTime; using NodaTime.Text; namespace PluralKit.Core { public static class DateTimeFormats { public static IPattern TimestampExportFormat = InstantPattern.ExtendedIso; public static IPattern DateExportFormat = LocalDatePattern.CreateWithInvariantCulture("yyyy-MM-dd"); // We create a composite pattern that only shows the two most significant things // eg. if we have something with nonzero day component, we show d h, but if it's // a smaller duration we may only bother with showing h m or m s public static IPattern DurationFormat = new CompositePatternBuilder { {DurationPattern.CreateWithInvariantCulture("s's'"), d => true}, {DurationPattern.CreateWithInvariantCulture("m'm' s's'"), d => d.Minutes > 0}, {DurationPattern.CreateWithInvariantCulture("H'h' m'm'"), d => d.Hours > 0}, {DurationPattern.CreateWithInvariantCulture("D'd' h'h'"), d => d.Days > 0} }.Build(); public static IPattern LocalDateTimeFormat = LocalDateTimePattern.CreateWithInvariantCulture("yyyy-MM-dd HH:mm:ss"); public static IPattern ZonedDateTimeFormat = ZonedDateTimePattern.CreateWithInvariantCulture("yyyy-MM-dd HH:mm:ss x", DateTimeZoneProviders.Tzdb); } }