|
@@ -19,16 +19,20 @@
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
*/
|
|
|
+
|
|
|
+import php.Global.*;
|
|
|
+import php.Syntax.*;
|
|
|
+
|
|
|
@:coreApi @:final class Date
|
|
|
{
|
|
|
private var __t : Float;
|
|
|
|
|
|
public function new(year : Int, month : Int, day : Int, hour : Int, min : Int, sec : Int ) : Void {
|
|
|
- __t = untyped __call__("mktime", hour, min, sec, month+1, day, year);
|
|
|
+ __t = mktime(hour, min, sec, month + 1, day, year);
|
|
|
}
|
|
|
|
|
|
public function getTime() : Float {
|
|
|
- return __t * 1000;
|
|
|
+ return __t * 1000.0;
|
|
|
}
|
|
|
|
|
|
private function getPhpTime() : Float {
|
|
@@ -36,56 +40,56 @@
|
|
|
}
|
|
|
|
|
|
public function getFullYear() : Int {
|
|
|
- return untyped __call__("intval", __call__("date", "Y", this.__t));
|
|
|
+ return int(date("Y", int(__t)));
|
|
|
}
|
|
|
|
|
|
public function getMonth() : Int {
|
|
|
- var m : Int = untyped __call__("intval", __call__("date", "n", this.__t));
|
|
|
+ var m : Int = int(date("n", int(__t)));
|
|
|
return -1 + m;
|
|
|
}
|
|
|
|
|
|
public function getDate() : Int {
|
|
|
- return untyped __call__("intval", __call__("date", "j", this.__t));
|
|
|
+ return int(date("j", int(__t)));
|
|
|
}
|
|
|
|
|
|
public function getHours() : Int {
|
|
|
- return untyped __call__("intval", __call__("date", "G", this.__t));
|
|
|
+ return int(date("G", int(__t)));
|
|
|
}
|
|
|
|
|
|
public function getMinutes() : Int {
|
|
|
- return untyped __call__("intval", __call__("date", "i", this.__t));
|
|
|
+ return int(date("i", int(__t)));
|
|
|
}
|
|
|
|
|
|
public function getSeconds() : Int {
|
|
|
- return untyped __call__("intval", __call__("date", "s", this.__t));
|
|
|
+ return int(date("s", int(__t)));
|
|
|
}
|
|
|
|
|
|
public function getDay() : Int {
|
|
|
- return untyped __call__("intval", __call__("date", "w", this.__t));
|
|
|
+ return int(date("w", int(__t)));
|
|
|
}
|
|
|
|
|
|
public function toString():String {
|
|
|
- return untyped __call__("date", "Y-m-d H:i:s", this.__t);
|
|
|
+ return date("Y-m-d H:i:s", int(__t));
|
|
|
}
|
|
|
|
|
|
public static function now() : Date {
|
|
|
- return fromPhpTime(untyped __call__("round", __call__("microtime", true), 3));
|
|
|
+ return fromPhpTime(round(microtime(true), 3));
|
|
|
}
|
|
|
|
|
|
static function fromPhpTime( t : Float ) : Date {
|
|
|
- var d = new Date(2000,1,1,0,0,0);
|
|
|
+ var d = new Date(2000, 1, 1, 0, 0, 0);
|
|
|
d.__t = t;
|
|
|
return d;
|
|
|
}
|
|
|
|
|
|
public static function fromTime( t : Float ) : Date {
|
|
|
- var d = new Date(2000,1,1,0,0,0);
|
|
|
+ var d = new Date(2000, 1, 1, 0, 0, 0);
|
|
|
d.__t = t / 1000;
|
|
|
return d;
|
|
|
}
|
|
|
|
|
|
public static function fromString( s : String ) : Date {
|
|
|
- return fromPhpTime(untyped __call__("strtotime", s));
|
|
|
+ return fromPhpTime(strtotime(s));
|
|
|
}
|
|
|
}
|
|
|
|