Browse Source

Add fromTime()

Pascal Peridont 19 years ago
parent
commit
4b0c7d2522
1 changed files with 11 additions and 0 deletions
  1. 11 0
      std/Date.hx

+ 11 - 0
std/Date.hx

@@ -30,12 +30,18 @@ extern class Date
 	function toString():String;
 	function toString():String;
 
 
 	static function now() : Date;
 	static function now() : Date;
+	static function fromTime( t : Float ) : Date;
 
 
 	private static function __init__() : Void untyped {
 	private static function __init__() : Void untyped {
 	#if js
 	#if js
 		Date.now = function() {
 		Date.now = function() {
 			return __new__(Date);
 			return __new__(Date);
 		};
 		};
+		Date.fromTime = function(t){
+			var d = __new__(Date);
+			d.setTime( t );
+			return d;
+		};
 		Date.prototype.toString = function() {
 		Date.prototype.toString = function() {
 			var m = this.getMonth() + 1;
 			var m = this.getMonth() + 1;
 			var d = this.getDate();
 			var d = this.getDate();
@@ -58,6 +64,11 @@ extern class Date
 		Date.now = function() {
 		Date.now = function() {
 			return __new__(Date);
 			return __new__(Date);
 		};
 		};
+		Date.fromTime = function(t){
+			var d = __new__(Date);
+			d.setTime( t );
+			return d;
+		};
 		Date.prototype.toString = function() {
 		Date.prototype.toString = function() {
 			var m = this.getMonth() + 1;
 			var m = this.getMonth() + 1;
 			var d = this.getDate();
 			var d = this.getDate();