From 08c2ba5778c7066a81cade44d7376c15591935f8 Mon Sep 17 00:00:00 2001 From: Daniel Chalmers Date: Mon, 15 Jul 2024 22:10:21 -0500 Subject: [PATCH] List all standard format strings in the menu Standard strings are better because they conform to the user's locale. --- DesktopClock/DateFormatExample.cs | 56 +++++++++++++++++++------------ 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/DesktopClock/DateFormatExample.cs b/DesktopClock/DateFormatExample.cs index ff0896e..0fd6e86 100644 --- a/DesktopClock/DateFormatExample.cs +++ b/DesktopClock/DateFormatExample.cs @@ -32,28 +32,40 @@ private DateFormatExample(string format, string example) /// /// Common date time formatting strings and an example string for each. /// - /// https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings + /// + /// Standard date and time format strings + ///
+ /// Custom date and time format strings + ///
public static IReadOnlyCollection DefaultExamples { get; } = new[] { - "M", - "dddd, MMMM dd", - "dddd, MMMM dd, HH:mm", - "dddd, MMMM dd, h:mm tt", - "dddd, MMM dd, HH:mm", - "dddd, MMM dd, h:mm tt", - "dddd, MMM dd, HH:mm:ss", - "dddd, MMM dd, h:mm:ss tt", - "ddd, MMM dd, HH:mm", - "ddd, MMM dd, h:mm tt", - "ddd, MMM dd, HH:mm:ss", - "ddd, MMM dd, h:mm:ss tt", - "ddd, MMM dd, HH:mm K", - "ddd, MMM dd, h:mm tt K", - "d", - "g", - "G", - "t", - "T", - "O", + "dddd, MMMM dd", // Custom format: "Monday, April 10" + "dddd, MMMM dd, HH:mm", // Custom format: "Monday, April 10, 14:30" + "dddd, MMMM dd, h:mm tt", // Custom format: "Monday, April 10, 2:30 PM" + "dddd, MMM dd, HH:mm", // Custom format: "Monday, Apr 10, 14:30" + "dddd, MMM dd, h:mm tt", // Custom format: "Monday, Apr 10, 2:30 PM" + "dddd, MMM dd, HH:mm:ss", // Custom format: "Monday, Apr 10, 14:30:45" + "dddd, MMM dd, h:mm:ss tt", // Custom format: "Monday, Apr 10, 2:30:45 PM" + "ddd, MMM dd, HH:mm", // Custom format: "Mon, Apr 10, 14:30" + "ddd, MMM dd, h:mm tt", // Custom format: "Mon, Apr 10, 2:30 PM" + "ddd, MMM dd, HH:mm:ss", // Custom format: "Mon, Apr 10, 14:30:45" + "ddd, MMM dd, h:mm:ss tt", // Custom format: "Mon, Apr 10, 2:30:45 PM" + "ddd, MMM dd, HH:mm K", // Custom format: "Mon, Apr 10, 14:30 +02:00" + "ddd, MMM dd, h:mm tt K", // Custom format: "Mon, Apr 10, 2:30 PM +02:00" + "d", // Short date pattern: 6/15/2009 (en-US) + "D", // Long date pattern: Monday, June 15, 2009 (en-US) + "f", // Full date/time pattern (short time): Monday, June 15, 2009 1:45 PM (en-US) + "F", // Full date/time pattern (long time): Monday, June 15, 2009 1:45:30 PM (en-US) + "g", // General date/time pattern (short time): 6/15/2009 1:45 PM (en-US) + "G", // General date/time pattern (long time): 6/15/2009 1:45:30 PM (en-US) + "M", // Month/day pattern: June 15 (en-US) + "O", // Round-trip date/time pattern: 2009-06-15T13:45:30.0000000-07:00 (DateTimeOffset) + "R", // RFC1123 pattern: Mon, 15 Jun 2009 20:45:30 GMT (DateTimeOffset) + "s", // Sortable date/time pattern: 2009-06-15T13:45:30 + "t", // Short time pattern: 1:45 PM (en-US) + "T", // Long time pattern: 1:45:30 PM (en-US) + "u", // Universal sortable date/time pattern: 2009-06-15 13:45:30Z (DateTime) + //"U", // Universal full date/time pattern: Monday, June 15, 2009 8:45:30 PM (en-US) // Not available for DateTimeOffset. + "Y", // Year month pattern: June 2009 (en-US) }.Select(f => FromFormat(f, DateTimeOffset.Now)).Append(Tutorial).ToList(); -} \ No newline at end of file +}