mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-15 16:01:30 +00:00
Add initial Date bindings
Doesn't do much, yet, because we can't get the timezone with a plain binding, but it's at least something.
This commit is contained in:
37
std/assembly/date.ts
Normal file
37
std/assembly/date.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import {
|
||||
UTC as Date_UTC,
|
||||
now as Date_now
|
||||
} from "./bindings/Date";
|
||||
|
||||
export class Date {
|
||||
|
||||
@inline static UTC(
|
||||
year: i32,
|
||||
month: i32 = 0,
|
||||
day: i32 = 1,
|
||||
hour: i32 = 0,
|
||||
minute: i32 = 0,
|
||||
second: i32 = 0,
|
||||
millisecond: i32 = 0
|
||||
): i64 {
|
||||
return <i64>Date_UTC(year, month, day, hour, minute, second, millisecond);
|
||||
}
|
||||
|
||||
@inline static now(): i64 {
|
||||
return <i64>Date_now();
|
||||
}
|
||||
|
||||
private value: i64;
|
||||
|
||||
constructor(value: i64) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
getTime(): i64 {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
setTime(value: i64): void {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user