Browse Source

Rework default format options

Daniel Chalmers 4 years ago
parent
commit
3042275529
2 changed files with 23 additions and 8 deletions
  1. 22 7
      DesktopClock/DateTimeUtil.cs
  2. 1 1
      DesktopClock/MainWindow.xaml

+ 22 - 7
DesktopClock/DateTimeUtil.cs

@@ -7,18 +7,33 @@ namespace DesktopClock
     public static class DateTimeUtil
     {
         /// <summary>
-        /// Standard date and time formatting strings that are compatible with both <see cref="DateTime"/> and <see cref="DateTimeOffset"/>.
+        /// A collection of DateTime formatting strings.
         /// </summary>
-        /// <remarks>
-        /// https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings
-        /// </remarks>
-        public static IReadOnlyList<string> StandardDateTimeFormats { get; } = new[] { "d", "D", "f", "F", "g", "G", "M", "O", "R", "s", "t", "T", "u", "Y" };
+        public static IReadOnlyList<string> DateTimeFormats { get; } = new[]
+        {
+            "M",
+            "dddd, MMMM dd",
+            "dddd, MMMM dd, HH:mm",
+            "dddd, MMM dd, HH:mm",
+            "dddd, MMM dd, HH:mm:ss",
+            "ddd, MMMM dd, HH:mm",
+            "ddd, MMMM dd, HH:mm:ss",
+            "ddd, MMM dd, HH:mm",
+            "ddd, MMM dd, HH:mm:ss",
+            "ddd, MMM dd, HH:mm K",
+            "d",
+            "g",
+            "G",
+            "t",
+            "T",
+            "O",
+        };
 
         /// <summary>
         /// Common date time formatting strings and an example string for each.
         /// </summary>
-        public static IReadOnlyDictionary<string, string> StandardDateTimeFormatsAndExamples { get; } =
-            StandardDateTimeFormats.ToDictionary(f => f, f => DateTimeOffset.Now.ToString(f));
+        public static IReadOnlyDictionary<string, string> DateTimeFormatsAndExamples { get; } =
+            DateTimeFormats.ToDictionary(f => f, f => DateTimeOffset.Now.ToString(f));
 
         public static IReadOnlyCollection<TimeZoneInfo> TimeZones { get; } = TimeZoneInfo.GetSystemTimeZones();
 

+ 1 - 1
DesktopClock/MainWindow.xaml

@@ -68,7 +68,7 @@
             </MenuItem>
 
             <MenuItem Header="Format"
-                      ItemsSource="{x:Static local:DateTimeUtil.StandardDateTimeFormatsAndExamples}">
+                      ItemsSource="{x:Static local:DateTimeUtil.DateTimeFormatsAndExamples}">
                 <MenuItem.Resources>
                     <Style TargetType="MenuItem">
                         <Setter Property="Command" Value="{Binding DataContext.SetFormatCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" />