aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-07-14 14:36:02 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-07-14 14:36:02 -0400
commit008bb42caee73c5738dafd0b51a57d745d99b11e (patch)
tree819dee14909435fe3151d494feb0589d4d9afef3 /src
parentd09679619e7cf0fbae60e1f9220a6dbeb9de1bd7 (diff)
added d function to create date fields more easily
Diffstat (limited to 'src')
-rw-r--r--src/client/util/type_decls.d2
-rw-r--r--src/new_fields/DateField.ts6
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));
+});