Browse Source

Add Date getters

Pascal Peridont 19 years ago
parent
commit
432d853a6a
2 changed files with 33 additions and 0 deletions
  1. 7 0
      std/Date.hx
  2. 26 0
      std/neko/NekoDate__.hx

+ 7 - 0
std/Date.hx

@@ -40,6 +40,13 @@ extern class Date
 	**/
 	function getTime() : Float;
 
+	function getHours() : Int;
+	function getMinutes() : Int;
+	function getSeconds() : Int;
+	function getFullYear() : Int;
+	function getMonth() : Int;
+	function getDate() : Int;
+
 	/**
 		Returns a string representation for the Date, by using the
 		standard format [YYYY-MM-DD HH:MM:SS]. See [DateTools.format] for

+ 26 - 0
std/neko/NekoDate__.hx

@@ -37,6 +37,30 @@ class NekoDate__ //implements Date
 		return int32_to_float(__t) * 1000;
 	}
 
+	public function getFullYear() : Int {
+		return date_get_day(__t).y;
+	}
+
+	public function getMonth() : Int {
+		return date_get_day(__t).m -1;
+	}
+
+	public function getDate() : Int {
+		return date_get_day(__t).d;
+	}
+
+	public function getHours() : Int {
+		return date_get_hour(__t).h;
+	}
+
+	public function getMinutes() : Int {
+		return date_get_hour(__t).m;
+	}
+
+	public function getSeconds() : Int {
+		return date_get_hour(__t).s;
+	}
+
 	public function toString():String {
 		return new String(date_format(__t,null));
 	}
@@ -64,6 +88,8 @@ class NekoDate__ //implements Date
 	static var date_format = Lib.load("std","date_format",2);
 	static var date_set_hour = Lib.load("std","date_set_hour",4);
 	static var date_set_day = Lib.load("std","date_set_day",4);
+	static var date_get_day : Dynamic -> {y:Int, m:Int, d:Int} = Lib.load("std","date_get_day",1);
+	static var date_get_hour : Dynamic -> {h:Int, m:Int, s:Int} = Lib.load("std","date_get_hour",1);
 	static var int32_to_float = Lib.load("std","int32_to_float",1);
 	static var int32_add = Lib.load("std","int32_add",2);
 	static var int32_shl = Lib.load("std","int32_shl",2);