cvdl-ts 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DataSchema.d.ts +23 -9
- package/dist/DataSchema.js +43 -2
- package/package.json +1 -1
package/dist/DataSchema.d.ts
CHANGED
|
@@ -1,22 +1,36 @@
|
|
|
1
|
+
export declare namespace DateFormat {
|
|
2
|
+
type t = "YYYY-MM-DD" | "MM-DD-YYYY" | "DD-MM-YYYY" | "YYYY/MM/DD" | "MM/DD/YYYY" | "DD/MM/YYYY" | "Month, YYYY" | "DD Month, YYYY" | "Month DD, YYYY" | "Mon YYYY" | "Mon DD, YYYY" | "YYYY" | "unknown";
|
|
3
|
+
const formats: readonly ["YYYY-MM-DD", "MM-DD-YYYY", "DD-MM-YYYY", "YYYY/MM/DD", "MM/DD/YYYY", "DD/MM/YYYY", "Month, YYYY", "DD Month, YYYY", "Month DD, YYYY", "Mon YYYY", "Mon DD, YYYY", "YYYY", "unknown"];
|
|
4
|
+
const print: (date: string, format: t) => string;
|
|
5
|
+
const parse: (date: string) => string;
|
|
6
|
+
}
|
|
1
7
|
export declare namespace DocumentDataType {
|
|
2
|
-
type
|
|
8
|
+
type Date = {
|
|
3
9
|
tag: "Date";
|
|
4
|
-
|
|
10
|
+
format: DateFormat.t;
|
|
11
|
+
};
|
|
12
|
+
type PureString = {
|
|
5
13
|
tag: "String";
|
|
6
|
-
}
|
|
14
|
+
};
|
|
15
|
+
type MarkdownString = {
|
|
7
16
|
tag: "MarkdownString";
|
|
8
|
-
}
|
|
17
|
+
};
|
|
18
|
+
type PureNumber = {
|
|
9
19
|
tag: "Number";
|
|
10
|
-
}
|
|
20
|
+
};
|
|
21
|
+
type Type = {
|
|
11
22
|
tag: "Type";
|
|
12
23
|
value: string;
|
|
13
|
-
}
|
|
24
|
+
};
|
|
25
|
+
type List = {
|
|
14
26
|
tag: "List";
|
|
15
|
-
value: t;
|
|
16
|
-
}
|
|
27
|
+
value: DocumentDataType.t;
|
|
28
|
+
};
|
|
29
|
+
type Types = {
|
|
17
30
|
tag: "Types";
|
|
18
|
-
value: t[];
|
|
31
|
+
value: DocumentDataType.t[];
|
|
19
32
|
};
|
|
33
|
+
type t = Date | PureString | MarkdownString | PureNumber | Type | List | Types;
|
|
20
34
|
type DocumentDataType = t;
|
|
21
35
|
function parse(s: string): DocumentDataType;
|
|
22
36
|
function print(d: DocumentDataType): string;
|
package/dist/DataSchema.js
CHANGED
|
@@ -1,11 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DataSchema = exports.Field = exports.DocumentDataType = void 0;
|
|
3
|
+
exports.DataSchema = exports.Field = exports.DocumentDataType = exports.DateFormat = void 0;
|
|
4
|
+
var DateFormat;
|
|
5
|
+
(function (DateFormat) {
|
|
6
|
+
DateFormat.formats = [
|
|
7
|
+
"YYYY-MM-DD",
|
|
8
|
+
"MM-DD-YYYY",
|
|
9
|
+
"DD-MM-YYYY",
|
|
10
|
+
"YYYY/MM/DD",
|
|
11
|
+
"MM/DD/YYYY",
|
|
12
|
+
"DD/MM/YYYY",
|
|
13
|
+
"Month, YYYY",
|
|
14
|
+
"DD Month, YYYY",
|
|
15
|
+
"Month DD, YYYY",
|
|
16
|
+
"Mon YYYY",
|
|
17
|
+
"Mon DD, YYYY",
|
|
18
|
+
"YYYY",
|
|
19
|
+
"unknown"
|
|
20
|
+
];
|
|
21
|
+
DateFormat.print = (date, format) => {
|
|
22
|
+
console.error(date);
|
|
23
|
+
const d = new Date(date + "T00:00:00");
|
|
24
|
+
const year = d.getFullYear();
|
|
25
|
+
const month = d.getMonth() + 1;
|
|
26
|
+
const day = d.getDate();
|
|
27
|
+
let result = format;
|
|
28
|
+
result = result.replace("YYYY", year.toString());
|
|
29
|
+
result = result.replace("YY", year.toString().slice(-2));
|
|
30
|
+
result = result.replace("MM", month.toString().padStart(2, "0"));
|
|
31
|
+
result = result.replace("DD", day.toString().padStart(2, "0"));
|
|
32
|
+
result = result.replace("Month", d.toLocaleString('default', { month: 'long' }));
|
|
33
|
+
result = result.replace("Mon", d.toLocaleString('default', { month: 'short' }));
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
DateFormat.parse = (date) => {
|
|
37
|
+
const d = new Date(date + "T00:00:00");
|
|
38
|
+
console.error(d);
|
|
39
|
+
if (isNaN(d.getTime())) {
|
|
40
|
+
return "";
|
|
41
|
+
}
|
|
42
|
+
return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;
|
|
43
|
+
};
|
|
44
|
+
})(DateFormat || (exports.DateFormat = DateFormat = {}));
|
|
4
45
|
var DocumentDataType;
|
|
5
46
|
(function (DocumentDataType) {
|
|
6
47
|
function parse(s) {
|
|
7
48
|
if (s === "Date") {
|
|
8
|
-
return { tag: "Date" };
|
|
49
|
+
return { tag: "Date", format: s.length > 4 ? s.slice(5, -1).trim() : "YYYY-MM-DD" };
|
|
9
50
|
}
|
|
10
51
|
else if (s === "String") {
|
|
11
52
|
return { tag: "String" };
|