haxe/src/Date.cs
// Generated by Haxe 4.3.7

#pragma warning disable 109, 114, 219, 429, 168, 162
public class Date : global::haxe.lang.HxObject {
	
	public Date(global::haxe.lang.EmptyObject empty) {
	}
	
	
	public Date(global::System.DateTime native) {
		global::Date.__hx_ctor__Date(((global::Date) (this) ), ((global::System.DateTime) (native) ));
	}
	
	
	public Date(int year, int month, int day, int hour, int min, int sec) {
		global::Date.__hx_ctor__Date(((global::Date) (this) ), ((int) (year) ), ((int) (month) ), ((int) (day) ), ((int) (hour) ), ((int) (min) ), ((int) (sec) ));
	}
	
	
	protected static void __hx_ctor__Date(global::Date __hx_this, global::System.DateTime native) {
		if (( native.Kind == global::System.DateTimeKind.Utc )) {
			__hx_this.dateUTC = native;
			__hx_this.date = __hx_this.dateUTC.ToLocalTime();
		}
		else {
			__hx_this.date = native;
			__hx_this.dateUTC = __hx_this.date.ToUniversalTime();
		}
		
	}
	
	
	protected static void __hx_ctor__Date(global::Date __hx_this, int year, int month, int day, int hour, int min, int sec) {
		unchecked {
			if (( day <= 0 )) {
				day = 1;
			}
			
			if (( year <= 0 )) {
				year = 1;
			}
			
			__hx_this.date = new global::System.DateTime(((int) (year) ), ((int) (( month + 1 )) ), ((int) (day) ), ((int) (hour) ), ((int) (min) ), ((int) (sec) ), ((global::System.DateTimeKind) (global::System.DateTimeKind.Local) ));
			__hx_this.dateUTC = __hx_this.date.ToUniversalTime();
		}
	}
	
	
	public static readonly long epochTicks = new global::System.DateTime(((int) (1970) ), ((int) (1) ), ((int) (1) )).Ticks;
	
	public static global::Date now() {
		return new global::Date(((global::System.DateTime) (global::System.DateTime.Now) ));
	}
	
	
	public static global::Date fromTime(double t) {
		long ticks = ((long) (( ((long) (( t * ((double) (global::System.TimeSpan.TicksPerMillisecond) ) )) ) + ((long) (global::Date.epochTicks) ) )));
		global::System.DateTime utc = new global::System.DateTime(((long) (ticks) ), ((global::System.DateTimeKind) (global::System.DateTimeKind.Utc) ));
		return new global::Date(((global::System.DateTime) (utc.ToLocalTime()) ));
	}
	
	
	public static global::Date fromString(string s) {
		unchecked {
			switch (s.Length) {
				case 8:
				{
					global::Array<string> k = global::haxe.lang.StringExt.split(s, ":");
					return new global::Date(((global::System.DateTime) (new global::System.DateTime(((int) (1970) ), ((int) (1) ), ((int) (1) ), (global::Std.parseInt(k[0])).@value, (global::Std.parseInt(k[1])).@value, (global::Std.parseInt(k[2])).@value, ((global::System.DateTimeKind) (global::System.DateTimeKind.Utc) ))) ));
				}
				
				
				case 10:
				{
					global::Array<string> k1 = global::haxe.lang.StringExt.split(s, "-");
					return new global::Date(((global::System.DateTime) (new global::System.DateTime((global::Std.parseInt(k1[0])).@value, (global::Std.parseInt(k1[1])).@value, (global::Std.parseInt(k1[2])).@value, ((int) (0) ), ((int) (0) ), ((int) (0) ), ((global::System.DateTimeKind) (global::System.DateTimeKind.Local) ))) ));
				}
				
				
				case 19:
				{
					global::Array<string> k2 = global::haxe.lang.StringExt.split(s, " ");
					global::Array<string> y = global::haxe.lang.StringExt.split(k2[0], "-");
					global::Array<string> t = global::haxe.lang.StringExt.split(k2[1], ":");
					return new global::Date(((global::System.DateTime) (new global::System.DateTime((global::Std.parseInt(y[0])).@value, (global::Std.parseInt(y[1])).@value, (global::Std.parseInt(y[2])).@value, (global::Std.parseInt(t[0])).@value, (global::Std.parseInt(t[1])).@value, (global::Std.parseInt(t[2])).@value, ((global::System.DateTimeKind) (global::System.DateTimeKind.Local) ))) ));
				}
				
				
				default:
				{
					throw ((global::System.Exception) (global::haxe.Exception.thrown(global::haxe.lang.Runtime.concat("Invalid date format : ", s))) );
				}
				
			}
			
		}
	}
	
	
	public static global::Date fromNative(global::System.DateTime d) {
		return new global::Date(((global::System.DateTime) (d) ));
	}
	
	
	public global::System.DateTime date;
	
	public global::System.DateTime dateUTC;
	
	public double getTime() {
		return ( ((double) (((long) (( ((long) (this.date.ToUniversalTime().Ticks) ) - ((long) (global::Date.epochTicks) ) )) )) ) / ((double) (global::System.TimeSpan.TicksPerMillisecond) ) );
	}
	
	
	public int getHours() {
		return this.date.Hour;
	}
	
	
	public int getMinutes() {
		return this.date.Minute;
	}
	
	
	public int getSeconds() {
		return this.date.Second;
	}
	
	
	public int getFullYear() {
		return this.date.Year;
	}
	
	
	public int getMonth() {
		unchecked {
			return ( this.date.Month - 1 );
		}
	}
	
	
	public int getDate() {
		return this.date.Day;
	}
	
	
	public int getDay() {
		return ((int) (global::haxe.lang.Runtime.toInt(((object) (this.date.DayOfWeek) ))) );
	}
	
	
	public int getUTCHours() {
		return this.dateUTC.Hour;
	}
	
	
	public int getUTCMinutes() {
		return this.dateUTC.Minute;
	}
	
	
	public int getUTCSeconds() {
		return this.dateUTC.Second;
	}
	
	
	public int getUTCFullYear() {
		return this.dateUTC.Year;
	}
	
	
	public int getUTCMonth() {
		unchecked {
			return ( this.dateUTC.Month - 1 );
		}
	}
	
	
	public int getUTCDate() {
		return this.dateUTC.Day;
	}
	
	
	public int getUTCDay() {
		return ((int) (global::haxe.lang.Runtime.toInt(((object) (this.dateUTC.DayOfWeek) ))) );
	}
	
	
	public int getTimezoneOffset() {
		return ((int) (( ( ((double) (((long) (( ((long) (this.dateUTC.Ticks) ) - ((long) (this.date.Ticks) ) )) )) ) / ((double) (global::System.TimeSpan.TicksPerMillisecond) ) ) / 60000.0 )) );
	}
	
	
	public virtual string toString() {
		return this.date.ToString(((string) ("yyyy-MM-dd HH\\:mm\\:ss") ));
	}
	
	
	public override object __hx_setField(string field, int hash, object @value, bool handleProperties) {
		unchecked {
			switch (hash) {
				case 343868310:
				{
					this.dateUTC = ((global::System.DateTime) (@value) );
					return @value;
				}
				
				
				case 1113806382:
				{
					this.date = ((global::System.DateTime) (@value) );
					return @value;
				}
				
				
				default:
				{
					return base.__hx_setField(field, hash, @value, handleProperties);
				}
				
			}
			
		}
	}
	
	
	public override object __hx_getField(string field, int hash, bool throwErrors, bool isCheck, bool handleProperties) {
		unchecked {
			switch (hash) {
				case 946786476:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "toString", 946786476)) );
				}
				
				
				case 1171620962:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getTimezoneOffset", 1171620962)) );
				}
				
				
				case 1312666830:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getUTCDay", 1312666830)) );
				}
				
				
				case 666925948:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getUTCDate", 666925948)) );
				}
				
				
				case 1484998194:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getUTCMonth", 1484998194)) );
				}
				
				
				case 2029008698:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getUTCFullYear", 2029008698)) );
				}
				
				
				case 365188593:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getUTCSeconds", 365188593)) );
				}
				
				
				case 253048465:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getUTCMinutes", 253048465)) );
				}
				
				
				case 2005380545:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getUTCHours", 2005380545)) );
				}
				
				
				case 589000550:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getDay", 589000550)) );
				}
				
				
				case 350619108:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getDate", 350619108)) );
				}
				
				
				case 1815533258:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getMonth", 1815533258)) );
				}
				
				
				case 172955042:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getFullYear", 172955042)) );
				}
				
				
				case 703544457:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getSeconds", 703544457)) );
				}
				
				
				case 591404329:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getMinutes", 591404329)) );
				}
				
				
				case 188431961:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getHours", 188431961)) );
				}
				
				
				case 528448451:
				{
					return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "getTime", 528448451)) );
				}
				
				
				case 343868310:
				{
					return this.dateUTC;
				}
				
				
				case 1113806382:
				{
					return this.date;
				}
				
				
				default:
				{
					return base.__hx_getField(field, hash, throwErrors, isCheck, handleProperties);
				}
				
			}
			
		}
	}
	
	
	public override object __hx_invokeField(string field, int hash, object[] dynargs) {
		unchecked {
			switch (hash) {
				case 946786476:
				{
					return this.toString();
				}
				
				
				case 1171620962:
				{
					return this.getTimezoneOffset();
				}
				
				
				case 1312666830:
				{
					return this.getUTCDay();
				}
				
				
				case 666925948:
				{
					return this.getUTCDate();
				}
				
				
				case 1484998194:
				{
					return this.getUTCMonth();
				}
				
				
				case 2029008698:
				{
					return this.getUTCFullYear();
				}
				
				
				case 365188593:
				{
					return this.getUTCSeconds();
				}
				
				
				case 253048465:
				{
					return this.getUTCMinutes();
				}
				
				
				case 2005380545:
				{
					return this.getUTCHours();
				}
				
				
				case 589000550:
				{
					return this.getDay();
				}
				
				
				case 350619108:
				{
					return this.getDate();
				}
				
				
				case 1815533258:
				{
					return this.getMonth();
				}
				
				
				case 172955042:
				{
					return this.getFullYear();
				}
				
				
				case 703544457:
				{
					return this.getSeconds();
				}
				
				
				case 591404329:
				{
					return this.getMinutes();
				}
				
				
				case 188431961:
				{
					return this.getHours();
				}
				
				
				case 528448451:
				{
					return this.getTime();
				}
				
				
				default:
				{
					return base.__hx_invokeField(field, hash, dynargs);
				}
				
			}
			
		}
	}
	
	
	public override void __hx_getFields(global::Array<string> baseArr) {
		baseArr.push("dateUTC");
		baseArr.push("date");
		base.__hx_getFields(baseArr);
	}
	
	
	public override string ToString(){
		return this.toString();
	}
	
	
}