diff options
author | Tyler Schicke <tyler_schicke@brown.edu> | 2019-07-14 14:36:02 -0400 |
---|---|---|
committer | Tyler Schicke <tyler_schicke@brown.edu> | 2019-07-14 14:36:02 -0400 |
commit | 008bb42caee73c5738dafd0b51a57d745d99b11e (patch) | |
tree | 819dee14909435fe3151d494feb0589d4d9afef3 | |
parent | d09679619e7cf0fbae60e1f9220a6dbeb9de1bd7 (diff) |
added d function to create date fields more easily
-rw-r--r-- | src/client/util/type_decls.d | 2 | ||||
-rw-r--r-- | src/new_fields/DateField.ts | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/client/util/type_decls.d b/src/client/util/type_decls.d index 2cbe1dd40..1f95af00c 100644 --- a/src/client/util/type_decls.d +++ b/src/client/util/type_decls.d @@ -204,3 +204,5 @@ declare const Docs: { TreeDocument(documents: Doc[], options?: DocumentOptions): Doc; StackingDocument(documents: Doc[], options?: DocumentOptions): Doc; }; + +declare function d(...args:any[]):any; diff --git a/src/new_fields/DateField.ts b/src/new_fields/DateField.ts index fc8abb9d9..abec91e06 100644 --- a/src/new_fields/DateField.ts +++ b/src/new_fields/DateField.ts @@ -2,7 +2,9 @@ import { Deserializable } from "../client/util/SerializationHelper"; import { serializable, date } from "serializr"; import { ObjectField } from "./ObjectField"; import { Copy, ToScriptString } from "./FieldSymbols"; +import { scriptingGlobal, Scripting } from "../client/util/Scripting"; +@scriptingGlobal @Deserializable("date") export class DateField extends ObjectField { @serializable(date()) @@ -21,3 +23,7 @@ export class DateField extends ObjectField { return `new DateField(new Date(${this.date.toISOString()}))`; } } + +Scripting.addGlobal(function d(...dateArgs: any[]) { + return new DateField(new (Date as any)(...dateArgs)); +}); |