1- #pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type
2- #pragma warning disable CS8603 // Possible null reference return
3- #pragma warning disable CS1591 // Missing XML comment
41using System ;
52using System . Globalization ;
63namespace Sharpy
@@ -96,74 +93,87 @@ public string Strftime(string format)
9693
9794 // --- Arithmetic ---
9895
96+ /// <summary>Add a timedelta to the date.</summary>
9997 public static Date operator + ( Date date , Timedelta delta )
10098 {
10199 return new Date ( date . _date . AddTicks ( delta . InternalTimeSpan . Ticks ) . Date ) ;
102100 }
103101
102+ /// <summary>Subtract a timedelta from the date.</summary>
104103 public static Date operator - ( Date date , Timedelta delta )
105104 {
106105 return new Date ( date . _date . AddTicks ( - delta . InternalTimeSpan . Ticks ) . Date ) ;
107106 }
108107
108+ /// <summary>Return the timedelta between two dates.</summary>
109109 public static Timedelta operator - ( Date left , Date right )
110110 {
111111 return new Timedelta ( left . _date . Subtract ( right . _date ) ) ;
112112 }
113113
114114 // --- Comparison ---
115115
116- public int CompareTo ( Date other )
116+ /// <summary>Compare this date to another for ordering.</summary>
117+ public int CompareTo ( Date ? other )
117118 {
118- if ( other == null )
119+ if ( other is null )
119120 return 1 ;
120121 return _date . CompareTo ( other . _date ) ;
121122 }
122123
124+ /// <summary>Determine equality with another date.</summary>
123125 public bool Equals ( Date other )
124126 {
125127 if ( other is null )
126128 return false ;
127129 return _date == other . _date ;
128130 }
129131
132+ /// <summary>Determine equality with another object.</summary>
130133 public override bool Equals ( object obj )
131134 {
132135 return Equals ( obj as Date ) ;
133136 }
134137
138+ /// <summary>Return a hash code for this value.</summary>
135139 public override int GetHashCode ( )
136140 {
137141 return _date . GetHashCode ( ) ;
138142 }
139143
144+ /// <summary>Determine whether two dates are equal.</summary>
140145 public static bool operator == ( Date left , Date right )
141146 {
142147 if ( left is null )
143148 return right is null ;
144149 return left . Equals ( right ) ;
145150 }
146151
152+ /// <summary>Determine whether two dates are not equal.</summary>
147153 public static bool operator != ( Date left , Date right )
148154 {
149155 return ! ( left == right ) ;
150156 }
151157
158+ /// <summary>Determine whether the left date is earlier than the right.</summary>
152159 public static bool operator < ( Date left , Date right )
153160 {
154161 return left . CompareTo ( right ) < 0 ;
155162 }
156163
164+ /// <summary>Determine whether the left date is later than the right.</summary>
157165 public static bool operator > ( Date left , Date right )
158166 {
159167 return left . CompareTo ( right ) > 0 ;
160168 }
161169
170+ /// <summary>Determine whether the left date is earlier than or equal to the right.</summary>
162171 public static bool operator <= ( Date left , Date right )
163172 {
164173 return left . CompareTo ( right ) <= 0 ;
165174 }
166175
176+ /// <summary>Determine whether the left date is later than or equal to the right.</summary>
167177 public static bool operator >= ( Date left , Date right )
168178 {
169179 return left . CompareTo ( right ) >= 0 ;
@@ -223,57 +233,67 @@ public string Strftime(string format)
223233
224234 // --- Comparison ---
225235
226- public int CompareTo ( Time other )
236+ /// <summary>Compare this time to another for ordering.</summary>
237+ public int CompareTo ( Time ? other )
227238 {
228- if ( other == null )
239+ if ( other is null )
229240 return 1 ;
230241 return _time . CompareTo ( other . _time ) ;
231242 }
232243
244+ /// <summary>Determine equality with another time.</summary>
233245 public bool Equals ( Time other )
234246 {
235247 if ( other is null )
236248 return false ;
237249 return _time == other . _time ;
238250 }
239251
252+ /// <summary>Determine equality with another object.</summary>
240253 public override bool Equals ( object obj )
241254 {
242255 return Equals ( obj as Time ) ;
243256 }
244257
258+ /// <summary>Return a hash code for this value.</summary>
245259 public override int GetHashCode ( )
246260 {
247261 return _time . GetHashCode ( ) ;
248262 }
249263
264+ /// <summary>Determine whether two times are equal.</summary>
250265 public static bool operator == ( Time left , Time right )
251266 {
252267 if ( left is null )
253268 return right is null ;
254269 return left . Equals ( right ) ;
255270 }
256271
272+ /// <summary>Determine whether two times are not equal.</summary>
257273 public static bool operator != ( Time left , Time right )
258274 {
259275 return ! ( left == right ) ;
260276 }
261277
278+ /// <summary>Determine whether the left time is earlier than the right.</summary>
262279 public static bool operator < ( Time left , Time right )
263280 {
264281 return left . CompareTo ( right ) < 0 ;
265282 }
266283
284+ /// <summary>Determine whether the left time is later than the right.</summary>
267285 public static bool operator > ( Time left , Time right )
268286 {
269287 return left . CompareTo ( right ) > 0 ;
270288 }
271289
290+ /// <summary>Determine whether the left time is earlier than or equal to the right.</summary>
272291 public static bool operator <= ( Time left , Time right )
273292 {
274293 return left . CompareTo ( right ) <= 0 ;
275294 }
276295
296+ /// <summary>Determine whether the left time is later than or equal to the right.</summary>
277297 public static bool operator >= ( Time left , Time right )
278298 {
279299 return left . CompareTo ( right ) >= 0 ;
@@ -287,16 +307,16 @@ public override int GetHashCode()
287307 public class DateTime : IEquatable < DateTime > , IComparable < DateTime >
288308 {
289309 private readonly System . DateTime _dateTime ;
290- private readonly Timezone _tzinfo ;
310+ private readonly Timezone ? _tzinfo ;
291311
292312 /// <summary>Create a datetime from year, month, day, and optional time components.</summary>
293- public DateTime ( int year , int month , int day , int hour = 0 , int minute = 0 , int second = 0 , int microsecond = 0 , Timezone tzinfo = null )
313+ public DateTime ( int year , int month , int day , int hour = 0 , int minute = 0 , int second = 0 , int microsecond = 0 , Timezone ? tzinfo = null )
294314 {
295315 _dateTime = new System . DateTime ( year , month , day , hour , minute , second ) . AddTicks ( microsecond * 10L ) ;
296316 _tzinfo = tzinfo ;
297317 }
298318
299- internal DateTime ( System . DateTime dateTime , Timezone tzinfo = null )
319+ internal DateTime ( System . DateTime dateTime , Timezone ? tzinfo = null )
300320 {
301321 _dateTime = dateTime ;
302322 _tzinfo = tzinfo ;
0 commit comments