Quellcode durchsuchen

fix Date.getTime

frabbit vor 10 Jahren
Ursprung
Commit
51b3811e52

+ 1 - 4
std/python/_std/Date.hx

@@ -26,9 +26,6 @@ import python.Syntax;
 @:coreApi class Date
 @:coreApi class Date
 {
 {
 	static var EPOCH_UTC = Datetime.fromtimestamp(0, python.lib.datetime.Timezone.utc);
 	static var EPOCH_UTC = Datetime.fromtimestamp(0, python.lib.datetime.Timezone.utc);
-	static var EPOCH_LOCAL = Datetime.fromtimestamp(0);
-
-	var epoch : Datetime;
 
 
 	private var date:Datetime;
 	private var date:Datetime;
 
 
@@ -41,7 +38,7 @@ import python.Syntax;
 
 
 	public inline function getTime() : Float
 	public inline function getTime() : Float
 	{
 	{
-		return datetimeTimestamp(date, EPOCH_LOCAL);
+		return python.lib.Time.mktime(date.timetuple()) * 1000;
 	}
 	}
 
 
 	public inline function getHours() : Int
 	public inline function getHours() : Int

+ 3 - 0
std/python/lib/Time.hx

@@ -21,10 +21,13 @@
  */
  */
 package python.lib;
 package python.lib;
 
 
+import python.lib.time.StructTime;
+
 @:pythonImport("time")
 @:pythonImport("time")
 extern class Time {
 extern class Time {
 
 
 	public static function time ():Float;
 	public static function time ():Float;
 	public static function clock ():Float;
 	public static function clock ():Float;
 	public static function sleep (t:Float):Void;
 	public static function sleep (t:Float):Void;
+	public static function mktime(s:StructTime):Float;
 }
 }

+ 2 - 0
std/python/lib/datetime/Datetime.hx

@@ -21,6 +21,7 @@
  */
  */
 package python.lib.datetime;
 package python.lib.datetime;
 
 
+import python.lib.time.StructTime;
 
 
 @:pythonImport("datetime", "datetime")
 @:pythonImport("datetime", "datetime")
 extern class Datetime {
 extern class Datetime {
@@ -49,6 +50,7 @@ extern class Datetime {
 	public static function utcfromtimestamp (timestamp:Int):Datetime;
 	public static function utcfromtimestamp (timestamp:Int):Datetime;
 	public static function fromordinal (ordinal:Int):Datetime;
 	public static function fromordinal (ordinal:Int):Datetime;
 
 
+	public function timetuple():StructTime;
 	public function strftime (format:String):String;
 	public function strftime (format:String):String;
 	public function replace (?year:Int = 1970, ?month:Int = 1, ?day:Int = 1, ?hour:Int = 0, ?minute:Int = 0, ?second:Int, ?microsecond:Int, ?tzinfo:Tzinfo):Datetime;
 	public function replace (?year:Int = 1970, ?month:Int = 1, ?day:Int = 1, ?hour:Int = 0, ?minute:Int = 0, ?second:Int, ?microsecond:Int, ?tzinfo:Tzinfo):Datetime;
 	/* 0-6 */
 	/* 0-6 */

+ 9 - 0
std/python/lib/time/StructTime.hx

@@ -0,0 +1,9 @@
+package python.lib.time;
+
+@:pythonImport("time", "struct_time")
+extern class StructTime implements ArrayAccess<Int> {
+	
+
+	
+
+}