Skip to content

Commit 1947264

Browse files
author
Conner Bachmann
committed
feat(date): added setTimezone function
1 parent 5912e1a commit 1947264

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Date.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
import { define } from "./Util";
2-
define(Date, {
2+
define(Date.prototype, {
33
nowSeconds: function () {
44
return Math.floor(Date.now() / 1000);
55
},
6+
setTimezone: function (timezone: string) {
7+
return new Date(
8+
this.toLocaleString("en-US", {
9+
timezone,
10+
})
11+
);
12+
}
613
});
714

815
declare global {
916
//@ts-ignore
1017
interface DateConstructor {
1118
nowSeconds(): number;
19+
setTimezone(): Date;
1220
}
1321
}
1422

0 commit comments

Comments
 (0)