@@ -5,18 +5,37 @@ namespace SourceGit.Models
55{
66 public class DateTimeFormat
77 {
8- public string DateOnly { get ; set ; }
9- public string DateTime { get ; set ; }
8+ public string DateOnly
9+ {
10+ get ;
11+ set ;
12+ }
13+
14+ public string DateTime
15+ {
16+ get
17+ {
18+ if ( _use24Hours != Use24Hours || string . IsNullOrEmpty ( _dateTime ) )
19+ {
20+ _use24Hours = Use24Hours ;
21+ _dateTime = _use24Hours ? $ "{ DateOnly } HH:mm:ss" : $ "{ DateOnly } hh:mm:ss tt";
22+ }
23+
24+ return _dateTime ;
25+ }
26+ }
1027
1128 public string Example
1229 {
13- get => _example . ToString ( DateTime ) ;
30+ get
31+ {
32+ return new DateTime ( 2025 , 1 , 31 , 8 , 0 , 0 , DateTimeKind . Local ) . ToString ( DateOnly ) ;
33+ }
1434 }
1535
16- public DateTimeFormat ( string dateOnly , string dateTime )
36+ public DateTimeFormat ( string date )
1737 {
18- DateOnly = dateOnly ;
19- DateTime = dateTime ;
38+ DateOnly = date ;
2039 }
2140
2241 public static int ActiveIndex
@@ -25,26 +44,33 @@ public static int ActiveIndex
2544 set ;
2645 } = 0 ;
2746
47+ public static bool Use24Hours
48+ {
49+ get ;
50+ set ;
51+ } = true ;
52+
2853 public static DateTimeFormat Active
2954 {
3055 get => Supported [ ActiveIndex ] ;
3156 }
3257
3358 public static readonly List < DateTimeFormat > Supported = new List < DateTimeFormat >
3459 {
35- new DateTimeFormat ( "yyyy/MM/dd" , "yyyy/MM/dd, HH:mm:ss" ) ,
36- new DateTimeFormat ( "yyyy.MM.dd" , "yyyy.MM.dd, HH:mm:ss" ) ,
37- new DateTimeFormat ( "yyyy-MM-dd" , "yyyy-MM-dd, HH:mm:ss" ) ,
38- new DateTimeFormat ( "MM/dd/yyyy" , "MM/dd/yyyy, HH:mm:ss" ) ,
39- new DateTimeFormat ( "MM.dd.yyyy" , "MM.dd.yyyy, HH:mm:ss" ) ,
40- new DateTimeFormat ( "MM-dd-yyyy" , "MM-dd-yyyy, HH:mm:ss" ) ,
41- new DateTimeFormat ( "dd/MM/yyyy" , "dd/MM/yyyy, HH:mm:ss" ) ,
42- new DateTimeFormat ( "dd.MM.yyyy" , "dd.MM.yyyy, HH:mm:ss" ) ,
43- new DateTimeFormat ( "dd-MM-yyyy" , "dd-MM-yyyy, HH:mm:ss" ) ,
44- new DateTimeFormat ( "MMM d yyyy" , "MMM d yyyy, HH:mm:ss" ) ,
45- new DateTimeFormat ( "d MMM yyyy" , "d MMM yyyy, HH:mm:ss" ) ,
60+ new DateTimeFormat ( "yyyy/MM/dd" ) ,
61+ new DateTimeFormat ( "yyyy.MM.dd" ) ,
62+ new DateTimeFormat ( "yyyy-MM-dd" ) ,
63+ new DateTimeFormat ( "MM/dd/yyyy" ) ,
64+ new DateTimeFormat ( "MM.dd.yyyy" ) ,
65+ new DateTimeFormat ( "MM-dd-yyyy" ) ,
66+ new DateTimeFormat ( "dd/MM/yyyy" ) ,
67+ new DateTimeFormat ( "dd.MM.yyyy" ) ,
68+ new DateTimeFormat ( "dd-MM-yyyy" ) ,
69+ new DateTimeFormat ( "MMM d yyyy" ) ,
70+ new DateTimeFormat ( "d MMM yyyy" ) ,
4671 } ;
4772
48- private static readonly DateTime _example = new DateTime ( 2025 , 1 , 31 , 8 , 0 , 0 , DateTimeKind . Local ) ;
73+ private bool _use24Hours = true ;
74+ private string _dateTime = null ;
4975 }
5076}
0 commit comments