Improve date binding compatibility

This commit is contained in:
dcodeIO
2018-11-11 10:43:17 +01:00
parent 1fad3d26c7
commit 9ab7384122
6 changed files with 31 additions and 23 deletions

View File

@ -1,10 +1,12 @@
export declare function UTC(
// NOTE: Using i32 below saves us a f64.convert_s instruction and moves the responsibility for
// converting the value to the WASM/JS boundary.
year: i32,
month: i32,
day: i32,
hour: i32,
minute: i32,
second: i32,
millisecond: i32
millisecond: f64
): f64;
export declare function now(): f64;

View File

@ -12,9 +12,9 @@ export class Date {
hour: i32 = 0,
minute: i32 = 0,
second: i32 = 0,
millisecond: i32 = 0
millisecond: i64 = 0
): i64 {
return <i64>Date_UTC(year, month, day, hour, minute, second, millisecond);
return <i64>Date_UTC(year, month, day, hour, minute, second, <f64>millisecond);
}
@inline static now(): i64 {
@ -31,7 +31,8 @@ export class Date {
return this.value;
}
setTime(value: i64): void {
setTime(value: i64): i64 {
this.value = value;
return value;
}
}

View File

@ -675,7 +675,7 @@ declare class Date {
/** Returns the UTC timestamp of this date in milliseconds. */
getTime(): i64;
/** Sets the UTC timestamp of this date in milliseconds. */
setTime(value: i64): void;
setTime(value: i64): i64;
}
/** Environmental tracing function for debugging purposes. */

View File

@ -442,7 +442,7 @@ declare class Date {
/** Returns the UTC timestamp of this date in milliseconds. */
getTime(): number;
/** Sets the UTC timestamp of this date in milliseconds. */
setTime(value: number): void;
setTime(value: number): number;
}
declare namespace console {