@rvoh/dream 1.11.1 → 1.12.0
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/cjs/src/Dream.js +2 -2
- package/dist/cjs/src/helpers/CalendarDate.js +54 -70
- package/dist/cjs/src/helpers/DateTime.js +1 -0
- package/dist/cjs/src/helpers/sqlAttributes.js +14 -4
- package/dist/cjs/src/index.js +3 -2
- package/dist/esm/src/Dream.js +2 -2
- package/dist/esm/src/helpers/CalendarDate.js +52 -70
- package/dist/esm/src/helpers/DateTime.js +1 -0
- package/dist/esm/src/helpers/sqlAttributes.js +14 -4
- package/dist/esm/src/index.js +1 -1
- package/dist/types/src/helpers/CalendarDate.d.ts +20 -19
- package/dist/types/src/helpers/customPgParsers.d.ts +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/types/luxon/settings.d.ts +3 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Benchmark.html +2 -2
- package/docs/classes/CalendarDate.html +2 -4
- package/docs/classes/CheckConstraintViolation.html +3 -3
- package/docs/classes/CliFileWriter.html +2 -2
- package/docs/classes/ColumnOverflow.html +3 -3
- package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/DataIncompatibleWithDatabaseField.html +3 -3
- package/docs/classes/DataTypeColumnTypeMismatch.html +3 -3
- package/docs/classes/Decorators.html +19 -19
- package/docs/classes/Dream.html +115 -115
- package/docs/classes/DreamApp.html +4 -4
- package/docs/classes/DreamBin.html +2 -2
- package/docs/classes/DreamCLI.html +4 -4
- package/docs/classes/DreamImporter.html +2 -2
- package/docs/classes/DreamLogos.html +2 -2
- package/docs/classes/DreamMigrationHelpers.html +9 -9
- package/docs/classes/DreamSerializerBuilder.html +8 -8
- package/docs/classes/DreamTransaction.html +2 -2
- package/docs/classes/Encrypt.html +2 -2
- package/docs/classes/Env.html +2 -2
- package/docs/classes/GlobalNameNotSet.html +3 -3
- package/docs/classes/InvalidCalendarDate.html +12 -0
- package/docs/classes/KyselyQueryDriver.html +30 -30
- package/docs/classes/MissingSerializersDefinition.html +3 -3
- package/docs/classes/NonLoadedAssociation.html +3 -3
- package/docs/classes/NotNullViolation.html +3 -3
- package/docs/classes/ObjectSerializerBuilder.html +8 -8
- package/docs/classes/PostgresQueryDriver.html +31 -31
- package/docs/classes/Query.html +54 -54
- package/docs/classes/QueryDriverBase.html +29 -29
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +3 -3
- package/docs/classes/ValidationError.html +3 -3
- package/docs/functions/DreamSerializer.html +1 -1
- package/docs/functions/ObjectSerializer.html +1 -1
- package/docs/functions/ReplicaSafe.html +1 -1
- package/docs/functions/STI.html +1 -1
- package/docs/functions/SoftDelete.html +1 -1
- package/docs/functions/camelize.html +1 -1
- package/docs/functions/capitalize.html +1 -1
- package/docs/functions/cloneDeepSafe.html +1 -1
- package/docs/functions/closeAllDbConnections.html +1 -1
- package/docs/functions/compact.html +1 -1
- package/docs/functions/dreamDbConnections.html +1 -1
- package/docs/functions/dreamPath.html +1 -1
- package/docs/functions/expandStiClasses.html +1 -1
- package/docs/functions/generateDream.html +1 -1
- package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/groupBy.html +1 -1
- package/docs/functions/hyphenize.html +1 -1
- package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
- package/docs/functions/inferSerializersFromDreamClassOrViewModelClass.html +1 -1
- package/docs/functions/intersection.html +1 -1
- package/docs/functions/isDreamSerializer.html +1 -1
- package/docs/functions/isEmpty.html +1 -1
- package/docs/functions/loadRepl.html +1 -1
- package/docs/functions/lookupClassByGlobalName.html +1 -1
- package/docs/functions/normalizeUnicode.html +1 -1
- package/docs/functions/pascalize.html +1 -1
- package/docs/functions/percent.html +1 -1
- package/docs/functions/pgErrorType.html +1 -1
- package/docs/functions/range-1.html +1 -1
- package/docs/functions/relativeDreamPath.html +1 -1
- package/docs/functions/round.html +1 -1
- package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/sharedPathPrefix.html +1 -1
- package/docs/functions/snakeify.html +1 -1
- package/docs/functions/sort.html +1 -1
- package/docs/functions/sortBy.html +1 -1
- package/docs/functions/sortObjectByKey.html +1 -1
- package/docs/functions/sortObjectByValue.html +1 -1
- package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
- package/docs/functions/uncapitalize.html +1 -1
- package/docs/functions/uniq.html +1 -1
- package/docs/functions/untypedDb.html +1 -1
- package/docs/functions/validateColumn.html +1 -1
- package/docs/functions/validateTable.html +1 -1
- package/docs/interfaces/BelongsToStatement.html +2 -2
- package/docs/interfaces/DecoratorContext.html +2 -2
- package/docs/interfaces/DreamAppInitOptions.html +2 -2
- package/docs/interfaces/DreamAppOpts.html +2 -2
- package/docs/interfaces/EncryptOptions.html +2 -2
- package/docs/interfaces/InternalAnyTypedSerializerRendersMany.html +2 -2
- package/docs/interfaces/InternalAnyTypedSerializerRendersOne.html +2 -2
- package/docs/interfaces/OpenapiDescription.html +2 -2
- package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
- package/docs/interfaces/SerializerRendererOpts.html +2 -2
- package/docs/modules.html +1 -0
- package/docs/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/DateTime.html +1 -1
- package/docs/types/DbConnectionType.html +1 -1
- package/docs/types/DbTypes.html +1 -1
- package/docs/types/DreamAppAllowedPackageManagersEnum.html +1 -1
- package/docs/types/DreamAssociationMetadata.html +1 -1
- package/docs/types/DreamAttributes.html +1 -1
- package/docs/types/DreamClassAssociationAndStatement.html +1 -1
- package/docs/types/DreamClassColumn.html +1 -1
- package/docs/types/DreamColumn.html +1 -1
- package/docs/types/DreamColumnNames.html +1 -1
- package/docs/types/DreamLogLevel.html +1 -1
- package/docs/types/DreamLogger.html +1 -1
- package/docs/types/DreamModelSerializerType.html +1 -1
- package/docs/types/DreamOrViewModelClassSerializerKey.html +1 -1
- package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/DreamParamSafeAttributes.html +1 -1
- package/docs/types/DreamParamSafeColumnNames.html +1 -1
- package/docs/types/DreamSerializable.html +1 -1
- package/docs/types/DreamSerializableArray.html +1 -1
- package/docs/types/DreamSerializerKey.html +1 -1
- package/docs/types/DreamSerializers.html +1 -1
- package/docs/types/DreamVirtualColumns.html +1 -1
- package/docs/types/EncryptAlgorithm.html +1 -1
- package/docs/types/HasManyStatement.html +1 -1
- package/docs/types/HasOneStatement.html +1 -1
- package/docs/types/Hyphenized.html +1 -1
- package/docs/types/OpenapiAllTypes.html +1 -1
- package/docs/types/OpenapiFormats.html +1 -1
- package/docs/types/OpenapiNumberFormats.html +1 -1
- package/docs/types/OpenapiPrimitiveBaseTypes.html +1 -1
- package/docs/types/OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiSchemaArray.html +1 -1
- package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/OpenapiSchemaBase.html +1 -1
- package/docs/types/OpenapiSchemaBody.html +1 -1
- package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/OpenapiSchemaInteger.html +1 -1
- package/docs/types/OpenapiSchemaNull.html +1 -1
- package/docs/types/OpenapiSchemaNumber.html +1 -1
- package/docs/types/OpenapiSchemaObject.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaString.html +1 -1
- package/docs/types/OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveBaseTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiTypeField.html +1 -1
- package/docs/types/Pascalized.html +1 -1
- package/docs/types/RoundingPrecision.html +1 -1
- package/docs/types/SerializerCasing.html +1 -1
- package/docs/types/SimpleObjectSerializerType.html +1 -1
- package/docs/types/Snakeified.html +1 -1
- package/docs/types/UpdateableAssociationProperties.html +1 -1
- package/docs/types/UpdateableProperties.html +1 -1
- package/docs/types/ValidationType.html +1 -1
- package/docs/types/ViewModel.html +1 -1
- package/docs/types/ViewModelClass.html +1 -1
- package/docs/types/WhereStatementForDream.html +1 -1
- package/docs/types/WhereStatementForDreamClass.html +1 -1
- package/docs/variables/DateTime-1.html +1 -1
- package/docs/variables/DreamAppAllowedPackageManagersEnumValues.html +1 -1
- package/docs/variables/DreamConst.html +1 -1
- package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
- package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/ops.html +1 -1
- package/docs/variables/primaryKeyTypes.html +1 -1
- package/package.json +1 -1
package/dist/cjs/src/Dream.js
CHANGED
|
@@ -2903,7 +2903,7 @@ class Dream {
|
|
|
2903
2903
|
currentValue = DateTime_js_1.DateTime.fromISO(currentValue);
|
|
2904
2904
|
if (currentValue instanceof CalendarDate_js_1.default)
|
|
2905
2905
|
currentValue = currentValue.toDateTime();
|
|
2906
|
-
if (currentValue instanceof DateTime_js_1.DateTime
|
|
2906
|
+
if (currentValue instanceof DateTime_js_1.DateTime)
|
|
2907
2907
|
return currentValue.toMillis();
|
|
2908
2908
|
}
|
|
2909
2909
|
/**
|
|
@@ -2916,7 +2916,7 @@ class Dream {
|
|
|
2916
2916
|
currentValue = CalendarDate_js_1.default.fromISO(currentValue);
|
|
2917
2917
|
if (currentValue instanceof DateTime_js_1.DateTime)
|
|
2918
2918
|
currentValue = CalendarDate_js_1.default.fromDateTime(currentValue);
|
|
2919
|
-
if (currentValue instanceof CalendarDate_js_1.default
|
|
2919
|
+
if (currentValue instanceof CalendarDate_js_1.default)
|
|
2920
2920
|
return currentValue.toISO();
|
|
2921
2921
|
}
|
|
2922
2922
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidCalendarDate = void 0;
|
|
3
4
|
const DateTime_js_1 = require("./DateTime.js");
|
|
4
5
|
class CalendarDate {
|
|
5
6
|
luxonDateTime;
|
|
@@ -9,11 +10,17 @@ class CalendarDate {
|
|
|
9
10
|
this.luxonDateTime = DateTime_js_1.DateTime.fromISO(isoDate, { zone: 'UTC' });
|
|
10
11
|
}
|
|
11
12
|
else if (typeof source === 'number') {
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
try {
|
|
14
|
+
this.luxonDateTime = DateTime_js_1.DateTime.utc(source, month, day);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (error instanceof Error)
|
|
18
|
+
throw new InvalidCalendarDate(error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
14
21
|
}
|
|
15
22
|
else {
|
|
16
|
-
this.luxonDateTime =
|
|
23
|
+
this.luxonDateTime = CalendarDate.today().toDateTime();
|
|
17
24
|
}
|
|
18
25
|
}
|
|
19
26
|
static fromDateTime(dateTime) {
|
|
@@ -22,20 +29,41 @@ class CalendarDate {
|
|
|
22
29
|
static fromJSDate(javascriptDate, { zone } = {}) {
|
|
23
30
|
return new CalendarDate(DateTime_js_1.DateTime.fromJSDate(javascriptDate, zone ? { zone } : undefined));
|
|
24
31
|
}
|
|
25
|
-
static newInvalidDate() {
|
|
26
|
-
return new CalendarDate(null);
|
|
27
|
-
}
|
|
28
32
|
static fromISO(str, { zone } = {}) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
let dateTime;
|
|
34
|
+
try {
|
|
35
|
+
dateTime = DateTime_js_1.DateTime.fromISO(str, zone ? { zone } : { setZone: true });
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error instanceof Error)
|
|
39
|
+
throw new InvalidCalendarDate(error);
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
return new CalendarDate(dateTime);
|
|
33
43
|
}
|
|
34
44
|
static fromSQL(str) {
|
|
35
|
-
|
|
45
|
+
let dateTime;
|
|
46
|
+
try {
|
|
47
|
+
dateTime = DateTime_js_1.DateTime.fromSQL(str, { zone: 'UTC' });
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (error instanceof Error)
|
|
51
|
+
throw new InvalidCalendarDate(error);
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
return new CalendarDate(dateTime);
|
|
36
55
|
}
|
|
37
56
|
static fromObject(obj, opts) {
|
|
38
|
-
|
|
57
|
+
let dateTime;
|
|
58
|
+
try {
|
|
59
|
+
dateTime = DateTime_js_1.DateTime.fromObject(obj, opts);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (error instanceof Error)
|
|
63
|
+
throw new InvalidCalendarDate(error);
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
return new CalendarDate(dateTime);
|
|
39
67
|
}
|
|
40
68
|
static today({ zone = 'UTC' } = {}) {
|
|
41
69
|
return new CalendarDate(DateTime_js_1.DateTime.now().setZone(zone));
|
|
@@ -46,33 +74,22 @@ class CalendarDate {
|
|
|
46
74
|
static yesterday(options = {}) {
|
|
47
75
|
return CalendarDate.today(options).minus({ day: 1 });
|
|
48
76
|
}
|
|
49
|
-
get isValid() {
|
|
50
|
-
if (this.luxonDateTime === null)
|
|
51
|
-
return false;
|
|
52
|
-
return this.luxonDateTime.isValid;
|
|
53
|
-
}
|
|
54
77
|
toISO() {
|
|
55
|
-
if (this.luxonDateTime === null)
|
|
56
|
-
return null;
|
|
57
78
|
return this.luxonDateTime.toISODate();
|
|
58
79
|
}
|
|
59
80
|
toSQL() {
|
|
60
|
-
if (this.luxonDateTime === null)
|
|
61
|
-
return null;
|
|
62
81
|
return this.luxonDateTime.toSQLDate();
|
|
63
82
|
}
|
|
64
83
|
toJSON() {
|
|
65
84
|
return this.toISO();
|
|
66
85
|
}
|
|
67
86
|
valueOf() {
|
|
68
|
-
return this.
|
|
87
|
+
return this.luxonDateTime.toMillis();
|
|
69
88
|
}
|
|
70
89
|
toISODate() {
|
|
71
90
|
return this.toISO();
|
|
72
91
|
}
|
|
73
92
|
toLocaleString(formatOpts, opts) {
|
|
74
|
-
if (this.luxonDateTime === null)
|
|
75
|
-
return null;
|
|
76
93
|
return this.luxonDateTime.toLocaleString(formatOpts, opts);
|
|
77
94
|
}
|
|
78
95
|
toString() {
|
|
@@ -82,91 +99,58 @@ class CalendarDate {
|
|
|
82
99
|
return this.luxonDateTime;
|
|
83
100
|
}
|
|
84
101
|
toJSDate() {
|
|
85
|
-
if (this.luxonDateTime === null)
|
|
86
|
-
return null;
|
|
87
102
|
return this.luxonDateTime.toJSDate();
|
|
88
103
|
}
|
|
89
104
|
get year() {
|
|
90
|
-
if (this.luxonDateTime === null)
|
|
91
|
-
return null;
|
|
92
105
|
return this.luxonDateTime.year;
|
|
93
106
|
}
|
|
94
107
|
get month() {
|
|
95
|
-
if (this.luxonDateTime === null)
|
|
96
|
-
return null;
|
|
97
108
|
return this.luxonDateTime.month;
|
|
98
109
|
}
|
|
99
110
|
get day() {
|
|
100
|
-
if (this.luxonDateTime === null)
|
|
101
|
-
return null;
|
|
102
111
|
return this.luxonDateTime.day;
|
|
103
112
|
}
|
|
104
113
|
startOf(period) {
|
|
105
|
-
if (this.luxonDateTime === null)
|
|
106
|
-
return CalendarDate.newInvalidDate();
|
|
107
114
|
return new CalendarDate(this.luxonDateTime.startOf(period));
|
|
108
115
|
}
|
|
109
116
|
endOf(period) {
|
|
110
|
-
if (this.luxonDateTime === null)
|
|
111
|
-
return CalendarDate.newInvalidDate();
|
|
112
117
|
return new CalendarDate(this.luxonDateTime.endOf(period));
|
|
113
118
|
}
|
|
114
119
|
plus(duration) {
|
|
115
|
-
if (this.luxonDateTime === null)
|
|
116
|
-
return CalendarDate.newInvalidDate();
|
|
117
120
|
return new CalendarDate(this.luxonDateTime.plus(duration));
|
|
118
121
|
}
|
|
119
122
|
minus(duration) {
|
|
120
|
-
if (this.luxonDateTime === null)
|
|
121
|
-
return CalendarDate.newInvalidDate();
|
|
122
123
|
return new CalendarDate(this.luxonDateTime.minus(duration));
|
|
123
124
|
}
|
|
124
|
-
static max(
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
return CalendarDate.newInvalidDate();
|
|
128
|
-
const otherDateTime = otherCalendarDate.toDateTime();
|
|
129
|
-
if (otherDateTime === null)
|
|
130
|
-
return CalendarDate.newInvalidDate();
|
|
131
|
-
return new CalendarDate(DateTime_js_1.DateTime.max(dateTime, otherDateTime));
|
|
125
|
+
static max(...calendarDates) {
|
|
126
|
+
const dateTimes = calendarDates.map(calendarDate => calendarDate.toDateTime());
|
|
127
|
+
return new CalendarDate(DateTime_js_1.DateTime.max(...dateTimes));
|
|
132
128
|
}
|
|
133
|
-
static min(
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
return CalendarDate.newInvalidDate();
|
|
137
|
-
const otherDateTime = otherCalendarDate.toDateTime();
|
|
138
|
-
if (otherDateTime === null)
|
|
139
|
-
return CalendarDate.newInvalidDate();
|
|
140
|
-
return new CalendarDate(DateTime_js_1.DateTime.min(dateTime, otherDateTime));
|
|
129
|
+
static min(...calendarDates) {
|
|
130
|
+
const dateTimes = calendarDates.map(calendarDate => calendarDate.toDateTime());
|
|
131
|
+
return new CalendarDate(DateTime_js_1.DateTime.min(...dateTimes));
|
|
141
132
|
}
|
|
142
133
|
hasSame(otherCalendarDate, period) {
|
|
143
|
-
if (this.luxonDateTime === null)
|
|
144
|
-
return false;
|
|
145
134
|
const otherDateTime = otherCalendarDate.toDateTime();
|
|
146
135
|
if (otherDateTime === null)
|
|
147
136
|
return false;
|
|
148
137
|
return this.luxonDateTime.hasSame(otherDateTime, period);
|
|
149
138
|
}
|
|
150
139
|
diff(otherCalendarDate, duration) {
|
|
151
|
-
if (this.luxonDateTime === null)
|
|
152
|
-
return null;
|
|
153
140
|
const otherDateTime = otherCalendarDate.toDateTime();
|
|
154
|
-
if (otherDateTime === null)
|
|
155
|
-
return null;
|
|
156
141
|
return this.luxonDateTime.diff(otherDateTime, duration)[duration];
|
|
157
142
|
}
|
|
158
143
|
diffNow(duration) {
|
|
159
|
-
if (this.luxonDateTime === null)
|
|
160
|
-
return null;
|
|
161
144
|
return Math.ceil(this.luxonDateTime.diffNow(duration)[duration]);
|
|
162
145
|
}
|
|
163
146
|
equals(otherCalendarDate) {
|
|
164
|
-
|
|
165
|
-
return otherCalendarDate.toDateTime() === null;
|
|
166
|
-
const otherDateTime = otherCalendarDate.toDateTime();
|
|
167
|
-
if (otherDateTime === null)
|
|
168
|
-
return this.luxonDateTime === null;
|
|
169
|
-
return this.luxonDateTime.equals(otherDateTime);
|
|
147
|
+
return this.luxonDateTime.equals(otherCalendarDate.toDateTime());
|
|
170
148
|
}
|
|
171
149
|
}
|
|
172
150
|
exports.default = CalendarDate;
|
|
151
|
+
class InvalidCalendarDate extends Error {
|
|
152
|
+
constructor(error) {
|
|
153
|
+
super((error.message ?? '').replace('DateTime', 'CalendarDate'));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.InvalidCalendarDate = InvalidCalendarDate;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = sqlAttributes;
|
|
4
4
|
const index_js_1 = require("../dream-app/index.js");
|
|
5
|
+
const DataTypeColumnTypeMismatch_js_1 = require("../errors/db/DataTypeColumnTypeMismatch.js");
|
|
5
6
|
const CalendarDate_js_1 = require("./CalendarDate.js");
|
|
6
7
|
const DateTime_js_1 = require("./DateTime.js");
|
|
7
8
|
const isDatetimeOrDatetimeArrayColumn_js_1 = require("./db/types/isDatetimeOrDatetimeArrayColumn.js");
|
|
@@ -17,13 +18,13 @@ function sqlAttributes(dream) {
|
|
|
17
18
|
return result;
|
|
18
19
|
if (Array.isArray(val)) {
|
|
19
20
|
if ((0, isDatetimeOrDatetimeArrayColumn_js_1.default)(dreamClass, key))
|
|
20
|
-
val = val.map(valueToDatetime);
|
|
21
|
+
val = val.map(aVal => valueToDatetime(dream, aVal));
|
|
21
22
|
else if ((0, isTextOrTextArrayColumn_js_1.default)(dreamClass, key))
|
|
22
23
|
val = val.map(normalizeUnicode_js_1.default);
|
|
23
24
|
}
|
|
24
25
|
else {
|
|
25
26
|
if ((0, isDatetimeOrDatetimeArrayColumn_js_1.default)(dreamClass, key))
|
|
26
|
-
val = valueToDatetime(val);
|
|
27
|
+
val = valueToDatetime(dream, val);
|
|
27
28
|
else if ((0, isTextOrTextArrayColumn_js_1.default)(dreamClass, key))
|
|
28
29
|
val = (0, normalizeUnicode_js_1.default)(val);
|
|
29
30
|
}
|
|
@@ -46,9 +47,18 @@ function sqlAttributes(dream) {
|
|
|
46
47
|
/**
|
|
47
48
|
* Convert datetimes to UTC
|
|
48
49
|
*/
|
|
49
|
-
function valueToDatetime(val) {
|
|
50
|
+
function valueToDatetime(dream, val) {
|
|
50
51
|
if (typeof val !== 'string')
|
|
51
52
|
return val;
|
|
52
|
-
|
|
53
|
+
let datetime;
|
|
54
|
+
try {
|
|
55
|
+
datetime = DateTime_js_1.DateTime.fromISO(val, { zone: 'UTC' });
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
throw new DataTypeColumnTypeMismatch_js_1.default({
|
|
59
|
+
dream,
|
|
60
|
+
error: error instanceof Error ? error : new Error('database column type error'),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
53
63
|
return datetime.isValid ? datetime : val;
|
|
54
64
|
}
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.ObjectSerializerBuilder = exports.DreamSerializerBuilder = exports.ObjectSerializer = exports.DreamSerializer = exports.serializerNameFromFullyQualifiedModelName = exports.isDreamSerializer = exports.inferSerializersFromDreamClassOrViewModelClass = exports.inferSerializerFromDreamOrViewModel = exports.ops = exports.uniq = exports.uncapitalize = exports.expandStiClasses = exports.standardizeFullyQualifiedModelName = exports.sortObjectByValue = exports.sortObjectByKey = exports.sortBy = exports.sort = exports.snakeify = exports.round = exports.range = exports.Range = exports.percent = exports.sharedPathPrefix = exports.relativeDreamPath = exports.dreamPath = exports.pascalize = exports.normalizeUnicode = exports.loadRepl = exports.isEmpty = exports.intersection = exports.hyphenize = exports.groupBy = void 0;
|
|
3
|
+
exports.Env = exports.DreamLogos = exports.DateTime = exports.compact = exports.cloneDeepSafe = exports.generateDream = exports.capitalize = exports.camelize = exports.InvalidCalendarDate = exports.CalendarDate = exports.Benchmark = exports.ValidationError = exports.MissingSerializersDefinition = exports.RecordNotFound = exports.GlobalNameNotSet = exports.NotNullViolation = exports.DataTypeColumnTypeMismatch = exports.DataIncompatibleWithDatabaseField = exports.ColumnOverflow = exports.CheckConstraintViolation = exports.CreateOrFindByFailedToCreateAndFind = exports.NonLoadedAssociation = exports.Encrypt = exports.PostgresQueryDriver = exports.KyselyQueryDriver = exports.QueryDriverBase = exports.Query = exports.DreamTransaction = exports.openapiShorthandPrimitiveTypes = exports.openapiPrimitiveTypes = exports.DreamConst = exports.Dream = exports.DreamAppAllowedPackageManagersEnumValues = exports.DreamApp = exports.lookupClassByGlobalName = exports.DreamImporter = exports.Decorators = exports.STI = exports.SoftDelete = exports.ReplicaSafe = exports.validateTable = exports.validateColumn = exports.DreamMigrationHelpers = exports.untypedDb = exports.pgErrorType = exports.dreamDbConnections = exports.closeAllDbConnections = exports.DreamCLI = exports.CliFileWriter = exports.DreamBin = void 0;
|
|
4
|
+
exports.ObjectSerializerBuilder = exports.DreamSerializerBuilder = exports.ObjectSerializer = exports.DreamSerializer = exports.serializerNameFromFullyQualifiedModelName = exports.isDreamSerializer = exports.inferSerializersFromDreamClassOrViewModelClass = exports.inferSerializerFromDreamOrViewModel = exports.ops = exports.uniq = exports.uncapitalize = exports.expandStiClasses = exports.standardizeFullyQualifiedModelName = exports.sortObjectByValue = exports.sortObjectByKey = exports.sortBy = exports.sort = exports.snakeify = exports.round = exports.range = exports.Range = exports.percent = exports.sharedPathPrefix = exports.relativeDreamPath = exports.dreamPath = exports.pascalize = exports.normalizeUnicode = exports.loadRepl = exports.isEmpty = exports.intersection = exports.hyphenize = exports.groupBy = exports.globalClassNameFromFullyQualifiedModelName = void 0;
|
|
5
5
|
var index_js_1 = require("./bin/index.js");
|
|
6
6
|
Object.defineProperty(exports, "DreamBin", { enumerable: true, get: function () { return index_js_1.default; } });
|
|
7
7
|
var CliFileWriter_js_1 = require("./cli/CliFileWriter.js");
|
|
@@ -80,6 +80,7 @@ var benchmark_js_1 = require("./helpers/benchmark.js");
|
|
|
80
80
|
Object.defineProperty(exports, "Benchmark", { enumerable: true, get: function () { return benchmark_js_1.default; } });
|
|
81
81
|
var CalendarDate_js_1 = require("./helpers/CalendarDate.js");
|
|
82
82
|
Object.defineProperty(exports, "CalendarDate", { enumerable: true, get: function () { return CalendarDate_js_1.default; } });
|
|
83
|
+
Object.defineProperty(exports, "InvalidCalendarDate", { enumerable: true, get: function () { return CalendarDate_js_1.InvalidCalendarDate; } });
|
|
83
84
|
var camelize_js_1 = require("./helpers/camelize.js");
|
|
84
85
|
Object.defineProperty(exports, "camelize", { enumerable: true, get: function () { return camelize_js_1.default; } });
|
|
85
86
|
var capitalize_js_1 = require("./helpers/capitalize.js");
|
package/dist/esm/src/Dream.js
CHANGED
|
@@ -2901,7 +2901,7 @@ export default class Dream {
|
|
|
2901
2901
|
currentValue = DateTime.fromISO(currentValue);
|
|
2902
2902
|
if (currentValue instanceof CalendarDate)
|
|
2903
2903
|
currentValue = currentValue.toDateTime();
|
|
2904
|
-
if (currentValue instanceof DateTime
|
|
2904
|
+
if (currentValue instanceof DateTime)
|
|
2905
2905
|
return currentValue.toMillis();
|
|
2906
2906
|
}
|
|
2907
2907
|
/**
|
|
@@ -2914,7 +2914,7 @@ export default class Dream {
|
|
|
2914
2914
|
currentValue = CalendarDate.fromISO(currentValue);
|
|
2915
2915
|
if (currentValue instanceof DateTime)
|
|
2916
2916
|
currentValue = CalendarDate.fromDateTime(currentValue);
|
|
2917
|
-
if (currentValue instanceof CalendarDate
|
|
2917
|
+
if (currentValue instanceof CalendarDate)
|
|
2918
2918
|
return currentValue.toISO();
|
|
2919
2919
|
}
|
|
2920
2920
|
/**
|
|
@@ -7,11 +7,17 @@ export default class CalendarDate {
|
|
|
7
7
|
this.luxonDateTime = DateTime.fromISO(isoDate, { zone: 'UTC' });
|
|
8
8
|
}
|
|
9
9
|
else if (typeof source === 'number') {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
try {
|
|
11
|
+
this.luxonDateTime = DateTime.utc(source, month, day);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (error instanceof Error)
|
|
15
|
+
throw new InvalidCalendarDate(error);
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
12
18
|
}
|
|
13
19
|
else {
|
|
14
|
-
this.luxonDateTime =
|
|
20
|
+
this.luxonDateTime = CalendarDate.today().toDateTime();
|
|
15
21
|
}
|
|
16
22
|
}
|
|
17
23
|
static fromDateTime(dateTime) {
|
|
@@ -20,20 +26,41 @@ export default class CalendarDate {
|
|
|
20
26
|
static fromJSDate(javascriptDate, { zone } = {}) {
|
|
21
27
|
return new CalendarDate(DateTime.fromJSDate(javascriptDate, zone ? { zone } : undefined));
|
|
22
28
|
}
|
|
23
|
-
static newInvalidDate() {
|
|
24
|
-
return new CalendarDate(null);
|
|
25
|
-
}
|
|
26
29
|
static fromISO(str, { zone } = {}) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
let dateTime;
|
|
31
|
+
try {
|
|
32
|
+
dateTime = DateTime.fromISO(str, zone ? { zone } : { setZone: true });
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (error instanceof Error)
|
|
36
|
+
throw new InvalidCalendarDate(error);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
return new CalendarDate(dateTime);
|
|
31
40
|
}
|
|
32
41
|
static fromSQL(str) {
|
|
33
|
-
|
|
42
|
+
let dateTime;
|
|
43
|
+
try {
|
|
44
|
+
dateTime = DateTime.fromSQL(str, { zone: 'UTC' });
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (error instanceof Error)
|
|
48
|
+
throw new InvalidCalendarDate(error);
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
return new CalendarDate(dateTime);
|
|
34
52
|
}
|
|
35
53
|
static fromObject(obj, opts) {
|
|
36
|
-
|
|
54
|
+
let dateTime;
|
|
55
|
+
try {
|
|
56
|
+
dateTime = DateTime.fromObject(obj, opts);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error instanceof Error)
|
|
60
|
+
throw new InvalidCalendarDate(error);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
return new CalendarDate(dateTime);
|
|
37
64
|
}
|
|
38
65
|
static today({ zone = 'UTC' } = {}) {
|
|
39
66
|
return new CalendarDate(DateTime.now().setZone(zone));
|
|
@@ -44,33 +71,22 @@ export default class CalendarDate {
|
|
|
44
71
|
static yesterday(options = {}) {
|
|
45
72
|
return CalendarDate.today(options).minus({ day: 1 });
|
|
46
73
|
}
|
|
47
|
-
get isValid() {
|
|
48
|
-
if (this.luxonDateTime === null)
|
|
49
|
-
return false;
|
|
50
|
-
return this.luxonDateTime.isValid;
|
|
51
|
-
}
|
|
52
74
|
toISO() {
|
|
53
|
-
if (this.luxonDateTime === null)
|
|
54
|
-
return null;
|
|
55
75
|
return this.luxonDateTime.toISODate();
|
|
56
76
|
}
|
|
57
77
|
toSQL() {
|
|
58
|
-
if (this.luxonDateTime === null)
|
|
59
|
-
return null;
|
|
60
78
|
return this.luxonDateTime.toSQLDate();
|
|
61
79
|
}
|
|
62
80
|
toJSON() {
|
|
63
81
|
return this.toISO();
|
|
64
82
|
}
|
|
65
83
|
valueOf() {
|
|
66
|
-
return this.
|
|
84
|
+
return this.luxonDateTime.toMillis();
|
|
67
85
|
}
|
|
68
86
|
toISODate() {
|
|
69
87
|
return this.toISO();
|
|
70
88
|
}
|
|
71
89
|
toLocaleString(formatOpts, opts) {
|
|
72
|
-
if (this.luxonDateTime === null)
|
|
73
|
-
return null;
|
|
74
90
|
return this.luxonDateTime.toLocaleString(formatOpts, opts);
|
|
75
91
|
}
|
|
76
92
|
toString() {
|
|
@@ -80,90 +96,56 @@ export default class CalendarDate {
|
|
|
80
96
|
return this.luxonDateTime;
|
|
81
97
|
}
|
|
82
98
|
toJSDate() {
|
|
83
|
-
if (this.luxonDateTime === null)
|
|
84
|
-
return null;
|
|
85
99
|
return this.luxonDateTime.toJSDate();
|
|
86
100
|
}
|
|
87
101
|
get year() {
|
|
88
|
-
if (this.luxonDateTime === null)
|
|
89
|
-
return null;
|
|
90
102
|
return this.luxonDateTime.year;
|
|
91
103
|
}
|
|
92
104
|
get month() {
|
|
93
|
-
if (this.luxonDateTime === null)
|
|
94
|
-
return null;
|
|
95
105
|
return this.luxonDateTime.month;
|
|
96
106
|
}
|
|
97
107
|
get day() {
|
|
98
|
-
if (this.luxonDateTime === null)
|
|
99
|
-
return null;
|
|
100
108
|
return this.luxonDateTime.day;
|
|
101
109
|
}
|
|
102
110
|
startOf(period) {
|
|
103
|
-
if (this.luxonDateTime === null)
|
|
104
|
-
return CalendarDate.newInvalidDate();
|
|
105
111
|
return new CalendarDate(this.luxonDateTime.startOf(period));
|
|
106
112
|
}
|
|
107
113
|
endOf(period) {
|
|
108
|
-
if (this.luxonDateTime === null)
|
|
109
|
-
return CalendarDate.newInvalidDate();
|
|
110
114
|
return new CalendarDate(this.luxonDateTime.endOf(period));
|
|
111
115
|
}
|
|
112
116
|
plus(duration) {
|
|
113
|
-
if (this.luxonDateTime === null)
|
|
114
|
-
return CalendarDate.newInvalidDate();
|
|
115
117
|
return new CalendarDate(this.luxonDateTime.plus(duration));
|
|
116
118
|
}
|
|
117
119
|
minus(duration) {
|
|
118
|
-
if (this.luxonDateTime === null)
|
|
119
|
-
return CalendarDate.newInvalidDate();
|
|
120
120
|
return new CalendarDate(this.luxonDateTime.minus(duration));
|
|
121
121
|
}
|
|
122
|
-
static max(
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
return CalendarDate.newInvalidDate();
|
|
126
|
-
const otherDateTime = otherCalendarDate.toDateTime();
|
|
127
|
-
if (otherDateTime === null)
|
|
128
|
-
return CalendarDate.newInvalidDate();
|
|
129
|
-
return new CalendarDate(DateTime.max(dateTime, otherDateTime));
|
|
122
|
+
static max(...calendarDates) {
|
|
123
|
+
const dateTimes = calendarDates.map(calendarDate => calendarDate.toDateTime());
|
|
124
|
+
return new CalendarDate(DateTime.max(...dateTimes));
|
|
130
125
|
}
|
|
131
|
-
static min(
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
return CalendarDate.newInvalidDate();
|
|
135
|
-
const otherDateTime = otherCalendarDate.toDateTime();
|
|
136
|
-
if (otherDateTime === null)
|
|
137
|
-
return CalendarDate.newInvalidDate();
|
|
138
|
-
return new CalendarDate(DateTime.min(dateTime, otherDateTime));
|
|
126
|
+
static min(...calendarDates) {
|
|
127
|
+
const dateTimes = calendarDates.map(calendarDate => calendarDate.toDateTime());
|
|
128
|
+
return new CalendarDate(DateTime.min(...dateTimes));
|
|
139
129
|
}
|
|
140
130
|
hasSame(otherCalendarDate, period) {
|
|
141
|
-
if (this.luxonDateTime === null)
|
|
142
|
-
return false;
|
|
143
131
|
const otherDateTime = otherCalendarDate.toDateTime();
|
|
144
132
|
if (otherDateTime === null)
|
|
145
133
|
return false;
|
|
146
134
|
return this.luxonDateTime.hasSame(otherDateTime, period);
|
|
147
135
|
}
|
|
148
136
|
diff(otherCalendarDate, duration) {
|
|
149
|
-
if (this.luxonDateTime === null)
|
|
150
|
-
return null;
|
|
151
137
|
const otherDateTime = otherCalendarDate.toDateTime();
|
|
152
|
-
if (otherDateTime === null)
|
|
153
|
-
return null;
|
|
154
138
|
return this.luxonDateTime.diff(otherDateTime, duration)[duration];
|
|
155
139
|
}
|
|
156
140
|
diffNow(duration) {
|
|
157
|
-
if (this.luxonDateTime === null)
|
|
158
|
-
return null;
|
|
159
141
|
return Math.ceil(this.luxonDateTime.diffNow(duration)[duration]);
|
|
160
142
|
}
|
|
161
143
|
equals(otherCalendarDate) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
144
|
+
return this.luxonDateTime.equals(otherCalendarDate.toDateTime());
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
export class InvalidCalendarDate extends Error {
|
|
148
|
+
constructor(error) {
|
|
149
|
+
super((error.message ?? '').replace('DateTime', 'CalendarDate'));
|
|
168
150
|
}
|
|
169
151
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import DreamApp from '../dream-app/index.js';
|
|
2
|
+
import DataTypeColumnTypeMismatch from '../errors/db/DataTypeColumnTypeMismatch.js';
|
|
2
3
|
import CalendarDate from './CalendarDate.js';
|
|
3
4
|
import { DateTime } from './DateTime.js';
|
|
4
5
|
import isDatetimeOrDatetimeArrayColumn from './db/types/isDatetimeOrDatetimeArrayColumn.js';
|
|
@@ -14,13 +15,13 @@ export default function sqlAttributes(dream) {
|
|
|
14
15
|
return result;
|
|
15
16
|
if (Array.isArray(val)) {
|
|
16
17
|
if (isDatetimeOrDatetimeArrayColumn(dreamClass, key))
|
|
17
|
-
val = val.map(valueToDatetime);
|
|
18
|
+
val = val.map(aVal => valueToDatetime(dream, aVal));
|
|
18
19
|
else if (isTextOrTextArrayColumn(dreamClass, key))
|
|
19
20
|
val = val.map(normalizeUnicode);
|
|
20
21
|
}
|
|
21
22
|
else {
|
|
22
23
|
if (isDatetimeOrDatetimeArrayColumn(dreamClass, key))
|
|
23
|
-
val = valueToDatetime(val);
|
|
24
|
+
val = valueToDatetime(dream, val);
|
|
24
25
|
else if (isTextOrTextArrayColumn(dreamClass, key))
|
|
25
26
|
val = normalizeUnicode(val);
|
|
26
27
|
}
|
|
@@ -43,9 +44,18 @@ export default function sqlAttributes(dream) {
|
|
|
43
44
|
/**
|
|
44
45
|
* Convert datetimes to UTC
|
|
45
46
|
*/
|
|
46
|
-
function valueToDatetime(val) {
|
|
47
|
+
function valueToDatetime(dream, val) {
|
|
47
48
|
if (typeof val !== 'string')
|
|
48
49
|
return val;
|
|
49
|
-
|
|
50
|
+
let datetime;
|
|
51
|
+
try {
|
|
52
|
+
datetime = DateTime.fromISO(val, { zone: 'UTC' });
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
throw new DataTypeColumnTypeMismatch({
|
|
56
|
+
dream,
|
|
57
|
+
error: error instanceof Error ? error : new Error('database column type error'),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
50
60
|
return datetime.isValid ? datetime : val;
|
|
51
61
|
}
|
package/dist/esm/src/index.js
CHANGED
|
@@ -34,7 +34,7 @@ export { default as RecordNotFound } from './errors/RecordNotFound.js';
|
|
|
34
34
|
export { default as MissingSerializersDefinition } from './errors/serializers/MissingSerializersDefinition.js';
|
|
35
35
|
export { default as ValidationError } from './errors/ValidationError.js';
|
|
36
36
|
export { default as Benchmark } from './helpers/benchmark.js';
|
|
37
|
-
export { default as CalendarDate } from './helpers/CalendarDate.js';
|
|
37
|
+
export { default as CalendarDate, InvalidCalendarDate } from './helpers/CalendarDate.js';
|
|
38
38
|
export { default as camelize } from './helpers/camelize.js';
|
|
39
39
|
export { default as capitalize } from './helpers/capitalize.js';
|
|
40
40
|
export { default as generateDream } from './helpers/cli/generateDream.js';
|
|
@@ -8,12 +8,11 @@ type CalendarDateDurationUnit = keyof Pick<DurationObjectUnits, 'years' | 'quart
|
|
|
8
8
|
type CalendarDateUnit = Extract<DateTimeUnit, 'year' | 'quarter' | 'month' | 'week' | 'day'>;
|
|
9
9
|
export default class CalendarDate {
|
|
10
10
|
private readonly luxonDateTime;
|
|
11
|
-
constructor(source
|
|
11
|
+
constructor(source?: DateTime | number | null, month?: number, day?: number);
|
|
12
12
|
static fromDateTime(dateTime: DateTime): CalendarDate;
|
|
13
13
|
static fromJSDate(javascriptDate: Date, { zone }?: {
|
|
14
14
|
zone?: string | Zone;
|
|
15
15
|
}): CalendarDate;
|
|
16
|
-
static newInvalidDate(): CalendarDate;
|
|
17
16
|
static fromISO(str: string, { zone }?: {
|
|
18
17
|
zone?: string | Zone;
|
|
19
18
|
}): CalendarDate;
|
|
@@ -28,28 +27,30 @@ export default class CalendarDate {
|
|
|
28
27
|
static yesterday(options?: {
|
|
29
28
|
zone?: string | Zone;
|
|
30
29
|
}): CalendarDate;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
get
|
|
42
|
-
get
|
|
43
|
-
get day(): number | null;
|
|
30
|
+
toISO(): string;
|
|
31
|
+
toSQL(): string;
|
|
32
|
+
toJSON(): string;
|
|
33
|
+
valueOf(): number;
|
|
34
|
+
toISODate(): string;
|
|
35
|
+
toLocaleString(formatOpts?: DateTimeFormatOptions, opts?: LocaleOptions): string;
|
|
36
|
+
toString(): string;
|
|
37
|
+
toDateTime(): DateTime;
|
|
38
|
+
toJSDate(): Date;
|
|
39
|
+
get year(): number;
|
|
40
|
+
get month(): number;
|
|
41
|
+
get day(): number;
|
|
44
42
|
startOf(period: CalendarDateUnit): CalendarDate;
|
|
45
43
|
endOf(period: CalendarDateUnit): CalendarDate;
|
|
46
44
|
plus(duration: CalendarDateDurationLike): CalendarDate;
|
|
47
45
|
minus(duration: CalendarDateDurationLike): CalendarDate;
|
|
48
|
-
static max(
|
|
49
|
-
static min(
|
|
46
|
+
static max(...calendarDates: Array<CalendarDate>): CalendarDate;
|
|
47
|
+
static min(...calendarDates: Array<CalendarDate>): CalendarDate;
|
|
50
48
|
hasSame(otherCalendarDate: CalendarDate, period: CalendarDateUnit): boolean;
|
|
51
|
-
diff(otherCalendarDate: CalendarDate, duration: CalendarDateDurationUnit): number
|
|
52
|
-
diffNow(duration: CalendarDateDurationUnit): number
|
|
49
|
+
diff(otherCalendarDate: CalendarDate, duration: CalendarDateDurationUnit): number;
|
|
50
|
+
diffNow(duration: CalendarDateDurationUnit): number;
|
|
53
51
|
equals(otherCalendarDate: CalendarDate): boolean;
|
|
54
52
|
}
|
|
53
|
+
export declare class InvalidCalendarDate extends Error {
|
|
54
|
+
constructor(error: Error);
|
|
55
|
+
}
|
|
55
56
|
export {};
|