|  | 
|  | 1 | +partial struct SYSTEMTIME | 
|  | 2 | +	: IEquatable<SYSTEMTIME> | 
|  | 3 | +{ | 
|  | 4 | +	public bool Equals(SYSTEMTIME other) => this.wYear == other.wYear && this.wMonth == other.wMonth && this.wDayOfWeek == other.wDayOfWeek && this.wDay == other.wDay && this.wHour == other.wHour && this.wMinute == other.wMinute && this.wSecond == other.wSecond && this.wMilliseconds == other.wMilliseconds; | 
|  | 5 | +	public override bool Equals(object obj) => obj is SYSTEMTIME other && this.Equals(other); | 
|  | 6 | +	public override int GetHashCode() => (this.wYear, this.wMonth, this.wDayOfWeek, this.wDay, this.wHour, this.wMinute, this.wSecond, this.wMilliseconds).GetHashCode(); | 
|  | 7 | +	public static bool operator ==(SYSTEMTIME d1, SYSTEMTIME d2) => d1.wYear == d2.wYear && d1.wMonth == d2.wMonth && d1.wDayOfWeek == d2.wDayOfWeek && d1.wDay == d2.wDay && d1.wHour == d2.wHour && d1.wMinute == d2.wMinute && d1.wSecond == d2.wSecond && d1.wMilliseconds == d2.wMilliseconds; | 
|  | 8 | +	public static bool operator !=(SYSTEMTIME d1, SYSTEMTIME d2) => d1.wYear != d2.wYear && d1.wMonth != d2.wMonth && d1.wDayOfWeek != d2.wDayOfWeek && d1.wDay != d2.wDay && d1.wHour != d2.wHour && d1.wMinute != d2.wMinute && d1.wSecond != d2.wSecond && d1.wMilliseconds != d2.wMilliseconds; | 
|  | 9 | + | 
|  | 10 | +	public static explicit operator global::System.DateTime(SYSTEMTIME sysTime) | 
|  | 11 | +	{ | 
|  | 12 | +		if (sysTime == default(SYSTEMTIME) || sysTime.wYear <= 0 || sysTime.wMonth <= 0 || sysTime.wDay <= 0) | 
|  | 13 | +		{ | 
|  | 14 | +			return default; | 
|  | 15 | +		} | 
|  | 16 | + | 
|  | 17 | +		// DateTime gets DayOfWeek automatically | 
|  | 18 | +		return new global::System.DateTime(sysTime.wYear, | 
|  | 19 | +			sysTime.wMonth, sysTime.wDay, sysTime.wHour, | 
|  | 20 | +			sysTime.wMinute, sysTime.wSecond, sysTime.wMilliseconds); | 
|  | 21 | +	} | 
|  | 22 | + | 
|  | 23 | +	public static explicit operator SYSTEMTIME(global::System.DateTime time) | 
|  | 24 | +	{ | 
|  | 25 | +		if (time == default) | 
|  | 26 | +		{ | 
|  | 27 | +			return default; | 
|  | 28 | +		} | 
|  | 29 | + | 
|  | 30 | +		return new SYSTEMTIME | 
|  | 31 | +		{ | 
|  | 32 | +			wYear = checked((ushort)time.Year), | 
|  | 33 | +			wMonth = checked((ushort)time.Month), | 
|  | 34 | +			wDayOfWeek = checked((ushort)time.DayOfWeek), | 
|  | 35 | +			wDay = checked((ushort)time.Day), | 
|  | 36 | +			wHour = checked((ushort)time.Hour), | 
|  | 37 | +			wMinute = checked((ushort)time.Minute), | 
|  | 38 | +			wSecond = checked((ushort)time.Second), | 
|  | 39 | +			wMilliseconds = checked((ushort)time.Millisecond) | 
|  | 40 | +		}; | 
|  | 41 | +	} | 
|  | 42 | +} | 
0 commit comments