Browse Source

date fixes.

Nicolas Cannasse 19 years ago
parent
commit
f759df3849
5 changed files with 53 additions and 45 deletions
  1. 52 0
      std/Date.hx
  2. 0 22
      std/flash/Boot.hx
  3. 0 21
      std/js/Boot.hx
  4. 0 1
      std/neko/Boot.hx
  5. 1 1
      std/neko/NekoDate__.hx

+ 52 - 0
std/Date.hx

@@ -30,6 +30,58 @@ extern class Date
 	function toString():String;
 
 	static function now() : Date;
+
+	private static function __init__() : Void untyped {
+	#if js
+		Date.now = function() {
+			return __new__(Date);
+		};
+		Date.prototype.toString = function() {
+			var m = this.getMonth() + 1;
+			var d = this.getDate();
+			var h = this.getHours();
+			var mi = this.getMinutes();
+			var s = this.getSeconds();
+			if( d < 10 )
+				d = "0" + d;
+			if( m < 10 )
+				m = "0" + m;
+			if( h < 10 )
+				h = "0" + h;
+			if( mi < 10 )
+				mi = "0" + mi;
+			if( s < 10 )
+				s = "0" + s;
+			return this.getFullYear()+"-"+m+"-"+d+" "+h+":"+mi+":"+s;
+		};
+	#else flash
+		Date.now = function() {
+			return __new__(Date);
+		};
+		Date.prototype.toString = function() {
+			var m = this.getMonth() + 1;
+			var d = this.getDate();
+			var h = this.getHours();
+			var mi = this.getMinutes();
+			var s = this.getSeconds();
+			if( d < 10 )
+				d = "0" + d;
+			if( m < 10 )
+				m = "0" + m;
+			if( h < 10 )
+				h = "0" + h;
+			if( mi < 10 )
+				mi = "0" + mi;
+			if( s < 10 )
+				s = "0" + s;
+			return this.getFullYear()+"-"+m+"-"+d+" "+h+":"+mi+":"+s;
+		};
+	#else neko
+		Date = neko.NekoDate__;
+	#else error
+	#end
+	}
+
 }
 
 

+ 0 - 22
std/flash/Boot.hx

@@ -238,28 +238,6 @@ class Boot {
 					}
 				}
 			};
-			Date.now = function() {
-				return __new__(Date);
-			};
-			Date.prototype.toString = function() {
-				var m = this.getMonth() + 1;
-				var d = this.getDate();
-				var h = this.getHours();
-				var mi = this.getMinutes();
-				var s = this.getSeconds();
-				if( d < 10 )
-					d = "0" + d;
-				if( m < 10 )
-					m = "0" + m;
-				if( h < 10 )
-					h = "0" + h;
-				if( mi < 10 )
-					mi = "0" + mi;
-				if( s < 10 )
-					s = "0" + s;
-				return this.getFullYear()+"-"+m+"-"+d+" "+h+":"+mi+":"+s;
-			};
-
 			// copy base classes from root to flash package
 			// we can't make a loop since we need to assign short-type-ids
 			flash.Accessibility = _global["Accessibility"];

+ 0 - 21
std/js/Boot.hx

@@ -212,27 +212,6 @@ class Boot {
 					}
 				}
 			};
-			Date.now = function() {
-				return __new__(Date);
-			};
-			Date.prototype.toString = function() {
-				var m = this.getMonth() + 1;
-				var d = this.getDate();
-				var h = this.getHours();
-				var mi = this.getMinutes();
-				var s = this.getSeconds();
-				if( d < 10 )
-					d = "0" + d;
-				if( m < 10 )
-					m = "0" + m;
-				if( h < 10 )
-					h = "0" + h;
-				if( mi < 10 )
-					mi = "0" + mi;
-				if( s < 10 )
-					s = "0" + s;
-				return this.getFullYear()+"-"+m+"-"+d+" "+h+":"+mi+":"+s;
-			};
 			var oldsub = String.prototype.substr;
 			String.prototype.substr = function(pos,len){
 				if( pos < 0 ){

+ 0 - 1
std/neko/Boot.hx

@@ -89,7 +89,6 @@ class Boot {
 			Array = NekoArray__;
 			Node = NekoNode__;
 			Math = NekoMath__;
-			Date = NekoDate__;
 			Int = __dollar__new(null);
 			Float = __dollar__new(null);
 			Bool = __dollar__new(null);

+ 1 - 1
std/neko/NekoDate__.hx

@@ -24,7 +24,7 @@
  */
 package neko;
 
-class NekoDate__ implements Date
+class NekoDate__ //implements Date
 {
 	private var __t : Void;