@rvoh/dream 2.2.3 → 2.3.0-alpha.2
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 +5 -5
- package/dist/cjs/src/db/dataTypes.js +1 -0
- package/dist/cjs/src/db/index.js +2 -2
- package/dist/cjs/src/dream/QueryDriver/Base.js +2 -2
- package/dist/cjs/src/dream/QueryDriver/Kysely.js +2 -2
- package/dist/cjs/src/dream/QueryDriver/helpers/kysely/checkForNeedToBeRunMigrations.js +2 -2
- package/dist/cjs/src/dream/QueryDriver/helpers/kysely/migrationFolderPath.js +6 -1
- package/dist/cjs/src/dream/QueryDriver/helpers/kysely/runMigration.js +2 -2
- package/dist/cjs/src/dream/internal/saveDream.js +1 -1
- package/dist/cjs/src/dream/internal/softDeleteDream.js +1 -1
- package/dist/cjs/src/dream-app/helpers/globalModelKeyFromPath.js +5 -2
- package/dist/cjs/src/dream-app/helpers/globalSerializerKeyFromPath.js +5 -2
- package/dist/cjs/src/dream-app/helpers/normalizeFilePath.js +3 -0
- package/dist/cjs/src/dream-app/index.js +3 -3
- package/dist/cjs/src/helpers/areEqual.js +2 -2
- package/dist/cjs/src/helpers/cli/ASTBuilder.js +2 -2
- package/dist/cjs/src/helpers/cloneDeepSafe.js +2 -2
- package/dist/cjs/src/helpers/customPgParsers.js +2 -2
- package/dist/cjs/src/helpers/loadRepl.js +2 -2
- package/dist/cjs/src/helpers/path/PathHelpers.js +27 -0
- package/dist/cjs/src/helpers/path/convertToFileURL.js +7 -0
- package/dist/cjs/src/helpers/path/windowsSafePath.js +22 -0
- package/dist/cjs/src/helpers/sortBy.js +2 -2
- package/dist/cjs/src/helpers/sqlAttributes.js +2 -2
- package/dist/cjs/src/helpers/stringCasing.js +2 -2
- package/dist/cjs/src/package-exports/errors.js +2 -1
- package/dist/cjs/src/package-exports/index.js +2 -2
- package/dist/cjs/src/package-exports/system.js +1 -0
- package/dist/cjs/src/serializer/SerializerRenderer.js +2 -2
- package/dist/cjs/src/types/calendardate.js +1 -0
- package/dist/cjs/src/types/datetime.js +1 -0
- package/dist/cjs/src/utils/datetime/CalendarDate.js +489 -0
- package/dist/cjs/src/utils/datetime/DateTime.js +1140 -0
- package/dist/cjs/src/utils/datetime/helpers/isoTimeDecimalString.js +8 -0
- package/dist/cjs/src/utils/datetime/helpers/microsecondParts.js +16 -0
- package/dist/cjs/src/utils/datetime/helpers/replaceISOMicroseconds.js +10 -0
- package/dist/esm/src/Dream.js +5 -5
- package/dist/esm/src/db/dataTypes.js +1 -0
- package/dist/esm/src/db/index.js +2 -2
- package/dist/esm/src/dream/QueryDriver/Base.js +2 -2
- package/dist/esm/src/dream/QueryDriver/Kysely.js +2 -2
- package/dist/esm/src/dream/QueryDriver/helpers/kysely/checkForNeedToBeRunMigrations.js +2 -2
- package/dist/esm/src/dream/QueryDriver/helpers/kysely/migrationFolderPath.js +6 -1
- package/dist/esm/src/dream/QueryDriver/helpers/kysely/runMigration.js +2 -2
- package/dist/esm/src/dream/internal/saveDream.js +1 -1
- package/dist/esm/src/dream/internal/softDeleteDream.js +1 -1
- package/dist/esm/src/dream-app/helpers/globalModelKeyFromPath.js +5 -2
- package/dist/esm/src/dream-app/helpers/globalSerializerKeyFromPath.js +5 -2
- package/dist/esm/src/dream-app/helpers/normalizeFilePath.js +3 -0
- package/dist/esm/src/dream-app/index.js +3 -3
- package/dist/esm/src/helpers/areEqual.js +2 -2
- package/dist/esm/src/helpers/cli/ASTBuilder.js +2 -2
- package/dist/esm/src/helpers/cloneDeepSafe.js +2 -2
- package/dist/esm/src/helpers/customPgParsers.js +2 -2
- package/dist/esm/src/helpers/loadRepl.js +2 -2
- package/dist/esm/src/helpers/path/PathHelpers.js +27 -0
- package/dist/esm/src/helpers/path/convertToFileURL.js +7 -0
- package/dist/esm/src/helpers/path/windowsSafePath.js +22 -0
- package/dist/esm/src/helpers/sortBy.js +2 -2
- package/dist/esm/src/helpers/sqlAttributes.js +2 -2
- package/dist/esm/src/helpers/stringCasing.js +2 -2
- package/dist/esm/src/package-exports/errors.js +2 -1
- package/dist/esm/src/package-exports/index.js +2 -2
- package/dist/esm/src/package-exports/system.js +1 -0
- package/dist/esm/src/serializer/SerializerRenderer.js +2 -2
- package/dist/esm/src/types/calendardate.js +1 -0
- package/dist/esm/src/types/datetime.js +1 -0
- package/dist/esm/src/utils/datetime/CalendarDate.js +489 -0
- package/dist/esm/src/utils/datetime/DateTime.js +1140 -0
- package/dist/esm/src/utils/datetime/helpers/isoTimeDecimalString.js +8 -0
- package/dist/esm/src/utils/datetime/helpers/microsecondParts.js +16 -0
- package/dist/esm/src/utils/datetime/helpers/replaceISOMicroseconds.js +10 -0
- package/dist/types/src/Dream.d.ts +1 -1
- package/dist/types/src/db/dataTypes.d.ts +2 -2
- package/dist/types/src/dream-app/helpers/normalizeFilePath.d.ts +1 -0
- package/dist/types/src/helpers/customPgParsers.d.ts +3 -2
- package/dist/types/src/helpers/path/PathHelpers.d.ts +21 -0
- package/dist/types/src/helpers/path/convertToFileURL.d.ts +1 -0
- package/dist/types/src/helpers/path/windowsSafePath.d.ts +20 -0
- package/dist/types/src/helpers/range.d.ts +2 -2
- package/dist/types/src/helpers/sort.d.ts +2 -2
- package/dist/types/src/helpers/sortBy.d.ts +2 -2
- package/dist/types/src/package-exports/errors.d.ts +2 -1
- package/dist/types/src/package-exports/index.d.ts +2 -2
- package/dist/types/src/package-exports/system.d.ts +1 -0
- package/dist/types/src/package-exports/types.d.ts +2 -0
- package/dist/types/src/types/associations/shared.d.ts +2 -2
- package/dist/types/src/types/associations/shared.ts +2 -2
- package/dist/types/src/types/calendardate.d.ts +4 -0
- package/dist/types/src/types/calendardate.ts +8 -0
- package/dist/types/src/types/datetime.d.ts +102 -0
- package/dist/types/src/types/datetime.ts +141 -0
- package/dist/types/src/types/dream.d.ts +2 -2
- package/dist/types/src/types/dream.ts +2 -2
- package/dist/types/src/types/moduleDeclarations/luxon.d.ts +5 -6
- package/dist/types/src/utils/datetime/CalendarDate.d.ts +375 -0
- package/dist/types/src/utils/datetime/DateTime.d.ts +773 -0
- package/dist/types/src/utils/datetime/helpers/isoTimeDecimalString.d.ts +4 -0
- package/dist/types/src/utils/datetime/helpers/microsecondParts.d.ts +10 -0
- package/dist/types/src/utils/datetime/helpers/replaceISOMicroseconds.d.ts +3 -0
- package/docs/assets/highlight.css +7 -0
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/db.DreamMigrationHelpers.html +9 -9
- package/docs/classes/db.KyselyQueryDriver.html +33 -33
- package/docs/classes/db.PostgresQueryDriver.html +34 -34
- package/docs/classes/db.QueryDriverBase.html +32 -32
- package/docs/classes/errors.CheckConstraintViolation.html +3 -3
- package/docs/classes/errors.ColumnOverflow.html +3 -3
- package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +3 -3
- package/docs/classes/errors.DataTypeColumnTypeMismatch.html +3 -3
- package/docs/classes/errors.GlobalNameNotSet.html +3 -3
- package/docs/classes/errors.InvalidCalendarDate.html +7 -2
- package/docs/classes/errors.InvalidDateTime.html +17 -0
- package/docs/classes/errors.MissingSerializersDefinition.html +3 -3
- package/docs/classes/errors.NonLoadedAssociation.html +3 -3
- package/docs/classes/errors.NotNullViolation.html +3 -3
- package/docs/classes/errors.RecordNotFound.html +3 -3
- package/docs/classes/errors.ValidationError.html +3 -3
- package/docs/classes/index.CalendarDate.html +195 -2
- package/docs/classes/index.DateTime.html +485 -0
- package/docs/classes/index.Decorators.html +19 -19
- package/docs/classes/index.Dream.html +121 -121
- package/docs/classes/index.DreamApp.html +5 -5
- package/docs/classes/index.DreamTransaction.html +2 -2
- package/docs/classes/index.Env.html +2 -2
- package/docs/classes/index.Query.html +59 -59
- package/docs/classes/system.CliFileWriter.html +2 -2
- package/docs/classes/system.DreamBin.html +2 -2
- package/docs/classes/system.DreamCLI.html +5 -5
- package/docs/classes/system.DreamImporter.html +2 -2
- package/docs/classes/system.DreamLogos.html +2 -2
- package/docs/classes/system.DreamSerializerBuilder.html +8 -8
- package/docs/classes/system.ObjectSerializerBuilder.html +8 -8
- package/docs/classes/system.PathHelpers.html +13 -0
- package/docs/classes/utils.Encrypt.html +2 -2
- package/docs/classes/utils.Range.html +2 -2
- package/docs/functions/db.closeAllDbConnections.html +1 -1
- package/docs/functions/db.dreamDbConnections.html +1 -1
- package/docs/functions/db.untypedDb.html +1 -1
- package/docs/functions/db.validateColumn.html +1 -1
- package/docs/functions/db.validateTable.html +1 -1
- package/docs/functions/errors.pgErrorType.html +1 -1
- package/docs/functions/index.DreamSerializer.html +1 -1
- package/docs/functions/index.ObjectSerializer.html +1 -1
- package/docs/functions/index.ReplicaSafe.html +1 -1
- package/docs/functions/index.STI.html +1 -1
- package/docs/functions/index.SoftDelete.html +1 -1
- package/docs/functions/utils.camelize.html +1 -1
- package/docs/functions/utils.capitalize.html +1 -1
- package/docs/functions/utils.cloneDeepSafe.html +1 -1
- package/docs/functions/utils.compact.html +2 -2
- package/docs/functions/utils.groupBy.html +1 -1
- package/docs/functions/utils.hyphenize.html +1 -1
- package/docs/functions/utils.intersection.html +1 -1
- package/docs/functions/utils.isEmpty.html +1 -1
- package/docs/functions/utils.normalizeUnicode.html +1 -1
- package/docs/functions/utils.pascalize.html +1 -1
- package/docs/functions/utils.percent.html +1 -1
- package/docs/functions/utils.range-1.html +1 -1
- package/docs/functions/utils.round.html +1 -1
- package/docs/functions/utils.sanitizeString.html +1 -1
- package/docs/functions/utils.snakeify.html +1 -1
- package/docs/functions/utils.sort.html +1 -1
- package/docs/functions/utils.sortBy.html +1 -1
- package/docs/functions/utils.sortObjectByKey.html +1 -1
- package/docs/functions/utils.sortObjectByValue.html +1 -1
- package/docs/functions/utils.uncapitalize.html +1 -1
- package/docs/functions/utils.uniq.html +1 -1
- package/docs/interfaces/openapi.OpenapiDescription.html +2 -2
- package/docs/interfaces/openapi.OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/openapi.OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/openapi.OpenapiTypeFieldObject.html +1 -1
- package/docs/interfaces/types.BelongsToStatement.html +2 -2
- package/docs/interfaces/types.DecoratorContext.html +2 -2
- package/docs/interfaces/types.DreamAppInitOptions.html +2 -2
- package/docs/interfaces/types.DreamAppOpts.html +2 -2
- package/docs/interfaces/types.DurationObject.html +12 -0
- package/docs/interfaces/types.EncryptOptions.html +2 -2
- package/docs/interfaces/types.InternalAnyTypedSerializerRendersMany.html +2 -2
- package/docs/interfaces/types.InternalAnyTypedSerializerRendersOne.html +2 -2
- package/docs/interfaces/types.SerializerRendererOpts.html +2 -2
- package/docs/modules/db.html +1 -1
- package/docs/modules/errors.html +2 -1
- package/docs/modules/index.html +3 -4
- package/docs/modules/openapi.html +1 -1
- package/docs/modules/system.html +2 -1
- package/docs/modules/types.html +6 -2
- package/docs/modules/utils.html +1 -1
- package/docs/types/openapi.CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/openapi.OpenapiAllTypes.html +1 -1
- package/docs/types/openapi.OpenapiFormats.html +1 -1
- package/docs/types/openapi.OpenapiNumberFormats.html +1 -1
- package/docs/types/openapi.OpenapiPrimitiveBaseTypes.html +1 -1
- package/docs/types/openapi.OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/openapi.OpenapiSchemaArray.html +1 -1
- package/docs/types/openapi.OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBase.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBody.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaInteger.html +1 -1
- package/docs/types/openapi.OpenapiSchemaNull.html +1 -1
- package/docs/types/openapi.OpenapiSchemaNumber.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObject.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/openapi.OpenapiSchemaString.html +1 -1
- package/docs/types/openapi.OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/openapi.OpenapiShorthandPrimitiveBaseTypes.html +1 -1
- package/docs/types/openapi.OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/openapi.OpenapiTypeField.html +1 -1
- package/docs/types/system.DreamAppAllowedPackageManagersEnum.html +1 -1
- package/docs/types/types.CalendarDateDurationUnit.html +1 -0
- package/docs/types/types.Camelized.html +1 -1
- package/docs/types/types.DbConnectionType.html +1 -1
- package/docs/types/types.DbTypes.html +1 -1
- package/docs/types/types.DreamAssociationMetadata.html +1 -1
- package/docs/types/types.DreamAttributes.html +1 -1
- package/docs/types/types.DreamClassAssociationAndStatement.html +1 -1
- package/docs/types/types.DreamClassColumn.html +1 -1
- package/docs/types/types.DreamColumn.html +1 -1
- package/docs/types/types.DreamColumnNames.html +1 -1
- package/docs/types/types.DreamLogLevel.html +1 -1
- package/docs/types/types.DreamLogger.html +1 -1
- package/docs/types/types.DreamModelSerializerType.html +1 -1
- package/docs/types/types.DreamOrViewModelClassSerializerKey.html +1 -1
- package/docs/types/types.DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/types.DreamParamSafeAttributes.html +1 -1
- package/docs/types/types.DreamParamSafeColumnNames.html +1 -1
- package/docs/types/types.DreamSerializable.html +1 -1
- package/docs/types/types.DreamSerializableArray.html +1 -1
- package/docs/types/types.DreamSerializerKey.html +1 -1
- package/docs/types/types.DreamSerializers.html +1 -1
- package/docs/types/types.DreamVirtualColumns.html +1 -1
- package/docs/types/types.DurationUnit.html +4 -0
- package/docs/types/types.EncryptAlgorithm.html +1 -1
- package/docs/types/types.HasManyStatement.html +1 -1
- package/docs/types/types.HasOneStatement.html +1 -1
- package/docs/types/types.Hyphenized.html +1 -1
- package/docs/types/types.Pascalized.html +1 -1
- package/docs/types/types.PrimaryKeyType.html +1 -1
- package/docs/types/types.RoundingPrecision.html +1 -1
- package/docs/types/types.SerializerCasing.html +1 -1
- package/docs/types/types.SimpleObjectSerializerType.html +1 -1
- package/docs/types/types.Snakeified.html +1 -1
- package/docs/types/types.StrictInterface.html +1 -1
- package/docs/types/types.UpdateableAssociationProperties.html +1 -1
- package/docs/types/types.UpdateableProperties.html +1 -1
- package/docs/types/types.ValidationType.html +1 -1
- package/docs/types/types.ViewModel.html +1 -1
- package/docs/types/types.ViewModelClass.html +1 -1
- package/docs/types/types.WeekdayName.html +2 -0
- package/docs/types/types.WhereStatementForDream.html +1 -1
- package/docs/types/types.WhereStatementForDreamClass.html +1 -1
- package/docs/variables/index.DreamConst.html +1 -1
- package/docs/variables/index.ops.html +1 -1
- package/docs/variables/openapi.openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapi.openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/system.DreamAppAllowedPackageManagersEnumValues.html +1 -1
- package/docs/variables/system.primaryKeyTypes.html +1 -1
- package/package.json +3 -2
- package/dist/cjs/src/helpers/CalendarDate.js +0 -151
- package/dist/cjs/src/helpers/DateTime.js +0 -4
- package/dist/esm/src/helpers/CalendarDate.js +0 -151
- package/dist/esm/src/helpers/DateTime.js +0 -4
- package/dist/types/src/helpers/CalendarDate.d.ts +0 -56
- package/dist/types/src/helpers/DateTime.d.ts +0 -6
- package/dist/types/src/types/luxon/_util.d.ts +0 -20
- package/dist/types/src/types/luxon/datetime.d.ts +0 -1759
- package/dist/types/src/types/luxon/duration.d.ts +0 -494
- package/dist/types/src/types/luxon/info.d.ts +0 -217
- package/dist/types/src/types/luxon/interval.d.ts +0 -357
- package/dist/types/src/types/luxon/misc.d.ts +0 -67
- package/dist/types/src/types/luxon/settings.d.ts +0 -91
- package/dist/types/src/types/luxon/zone.d.ts +0 -172
- package/docs/types/index.DateTime.html +0 -1
- package/docs/variables/index.DateTime-1.html +0 -1
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { DateTime } from './DateTime.js';
|
|
2
|
-
export default class CalendarDate {
|
|
3
|
-
luxonDateTime;
|
|
4
|
-
constructor(source, month = 1, day = 1) {
|
|
5
|
-
if (source instanceof DateTime && source.isValid) {
|
|
6
|
-
const isoDate = source.toISODate();
|
|
7
|
-
this.luxonDateTime = DateTime.fromISO(isoDate, { zone: 'UTC' });
|
|
8
|
-
}
|
|
9
|
-
else if (typeof source === 'number') {
|
|
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
|
-
}
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
this.luxonDateTime = CalendarDate.today().toDateTime();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
static fromDateTime(dateTime) {
|
|
24
|
-
return new CalendarDate(dateTime);
|
|
25
|
-
}
|
|
26
|
-
static fromJSDate(javascriptDate, { zone } = {}) {
|
|
27
|
-
return new CalendarDate(DateTime.fromJSDate(javascriptDate, zone ? { zone } : undefined));
|
|
28
|
-
}
|
|
29
|
-
static fromISO(str, { zone } = {}) {
|
|
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);
|
|
40
|
-
}
|
|
41
|
-
static fromSQL(str) {
|
|
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);
|
|
52
|
-
}
|
|
53
|
-
static fromObject(obj, opts) {
|
|
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);
|
|
64
|
-
}
|
|
65
|
-
static today({ zone = 'UTC' } = {}) {
|
|
66
|
-
return new CalendarDate(DateTime.now().setZone(zone));
|
|
67
|
-
}
|
|
68
|
-
static tomorrow(options = {}) {
|
|
69
|
-
return CalendarDate.today(options).plus({ day: 1 });
|
|
70
|
-
}
|
|
71
|
-
static yesterday(options = {}) {
|
|
72
|
-
return CalendarDate.today(options).minus({ day: 1 });
|
|
73
|
-
}
|
|
74
|
-
toISO() {
|
|
75
|
-
return this.luxonDateTime.toISODate();
|
|
76
|
-
}
|
|
77
|
-
toSQL() {
|
|
78
|
-
return this.luxonDateTime.toSQLDate();
|
|
79
|
-
}
|
|
80
|
-
toJSON() {
|
|
81
|
-
return this.toISO();
|
|
82
|
-
}
|
|
83
|
-
valueOf() {
|
|
84
|
-
return this.luxonDateTime.toMillis();
|
|
85
|
-
}
|
|
86
|
-
toISODate() {
|
|
87
|
-
return this.toISO();
|
|
88
|
-
}
|
|
89
|
-
toLocaleString(formatOpts, opts) {
|
|
90
|
-
return this.luxonDateTime.toLocaleString(formatOpts, opts);
|
|
91
|
-
}
|
|
92
|
-
toString() {
|
|
93
|
-
return this.toISO();
|
|
94
|
-
}
|
|
95
|
-
toDateTime() {
|
|
96
|
-
return this.luxonDateTime;
|
|
97
|
-
}
|
|
98
|
-
toJSDate() {
|
|
99
|
-
return this.luxonDateTime.toJSDate();
|
|
100
|
-
}
|
|
101
|
-
get year() {
|
|
102
|
-
return this.luxonDateTime.year;
|
|
103
|
-
}
|
|
104
|
-
get month() {
|
|
105
|
-
return this.luxonDateTime.month;
|
|
106
|
-
}
|
|
107
|
-
get day() {
|
|
108
|
-
return this.luxonDateTime.day;
|
|
109
|
-
}
|
|
110
|
-
startOf(period) {
|
|
111
|
-
return new CalendarDate(this.luxonDateTime.startOf(period));
|
|
112
|
-
}
|
|
113
|
-
endOf(period) {
|
|
114
|
-
return new CalendarDate(this.luxonDateTime.endOf(period));
|
|
115
|
-
}
|
|
116
|
-
plus(duration) {
|
|
117
|
-
return new CalendarDate(this.luxonDateTime.plus(duration));
|
|
118
|
-
}
|
|
119
|
-
minus(duration) {
|
|
120
|
-
return new CalendarDate(this.luxonDateTime.minus(duration));
|
|
121
|
-
}
|
|
122
|
-
static max(...calendarDates) {
|
|
123
|
-
const dateTimes = calendarDates.map(calendarDate => calendarDate.toDateTime());
|
|
124
|
-
return new CalendarDate(DateTime.max(...dateTimes));
|
|
125
|
-
}
|
|
126
|
-
static min(...calendarDates) {
|
|
127
|
-
const dateTimes = calendarDates.map(calendarDate => calendarDate.toDateTime());
|
|
128
|
-
return new CalendarDate(DateTime.min(...dateTimes));
|
|
129
|
-
}
|
|
130
|
-
hasSame(otherCalendarDate, period) {
|
|
131
|
-
const otherDateTime = otherCalendarDate.toDateTime();
|
|
132
|
-
if (otherDateTime === null)
|
|
133
|
-
return false;
|
|
134
|
-
return this.luxonDateTime.hasSame(otherDateTime, period);
|
|
135
|
-
}
|
|
136
|
-
diff(otherCalendarDate, duration) {
|
|
137
|
-
const otherDateTime = otherCalendarDate.toDateTime();
|
|
138
|
-
return this.luxonDateTime.diff(otherDateTime, duration)[duration];
|
|
139
|
-
}
|
|
140
|
-
diffNow(duration) {
|
|
141
|
-
return Math.ceil(this.luxonDateTime.diffNow(duration)[duration]);
|
|
142
|
-
}
|
|
143
|
-
equals(otherCalendarDate) {
|
|
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'));
|
|
150
|
-
}
|
|
151
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { DateTime } from './DateTime.js';
|
|
2
|
-
export default class CalendarDate {
|
|
3
|
-
luxonDateTime;
|
|
4
|
-
constructor(source, month = 1, day = 1) {
|
|
5
|
-
if (source instanceof DateTime && source.isValid) {
|
|
6
|
-
const isoDate = source.toISODate();
|
|
7
|
-
this.luxonDateTime = DateTime.fromISO(isoDate, { zone: 'UTC' });
|
|
8
|
-
}
|
|
9
|
-
else if (typeof source === 'number') {
|
|
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
|
-
}
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
this.luxonDateTime = CalendarDate.today().toDateTime();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
static fromDateTime(dateTime) {
|
|
24
|
-
return new CalendarDate(dateTime);
|
|
25
|
-
}
|
|
26
|
-
static fromJSDate(javascriptDate, { zone } = {}) {
|
|
27
|
-
return new CalendarDate(DateTime.fromJSDate(javascriptDate, zone ? { zone } : undefined));
|
|
28
|
-
}
|
|
29
|
-
static fromISO(str, { zone } = {}) {
|
|
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);
|
|
40
|
-
}
|
|
41
|
-
static fromSQL(str) {
|
|
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);
|
|
52
|
-
}
|
|
53
|
-
static fromObject(obj, opts) {
|
|
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);
|
|
64
|
-
}
|
|
65
|
-
static today({ zone = 'UTC' } = {}) {
|
|
66
|
-
return new CalendarDate(DateTime.now().setZone(zone));
|
|
67
|
-
}
|
|
68
|
-
static tomorrow(options = {}) {
|
|
69
|
-
return CalendarDate.today(options).plus({ day: 1 });
|
|
70
|
-
}
|
|
71
|
-
static yesterday(options = {}) {
|
|
72
|
-
return CalendarDate.today(options).minus({ day: 1 });
|
|
73
|
-
}
|
|
74
|
-
toISO() {
|
|
75
|
-
return this.luxonDateTime.toISODate();
|
|
76
|
-
}
|
|
77
|
-
toSQL() {
|
|
78
|
-
return this.luxonDateTime.toSQLDate();
|
|
79
|
-
}
|
|
80
|
-
toJSON() {
|
|
81
|
-
return this.toISO();
|
|
82
|
-
}
|
|
83
|
-
valueOf() {
|
|
84
|
-
return this.luxonDateTime.toMillis();
|
|
85
|
-
}
|
|
86
|
-
toISODate() {
|
|
87
|
-
return this.toISO();
|
|
88
|
-
}
|
|
89
|
-
toLocaleString(formatOpts, opts) {
|
|
90
|
-
return this.luxonDateTime.toLocaleString(formatOpts, opts);
|
|
91
|
-
}
|
|
92
|
-
toString() {
|
|
93
|
-
return this.toISO();
|
|
94
|
-
}
|
|
95
|
-
toDateTime() {
|
|
96
|
-
return this.luxonDateTime;
|
|
97
|
-
}
|
|
98
|
-
toJSDate() {
|
|
99
|
-
return this.luxonDateTime.toJSDate();
|
|
100
|
-
}
|
|
101
|
-
get year() {
|
|
102
|
-
return this.luxonDateTime.year;
|
|
103
|
-
}
|
|
104
|
-
get month() {
|
|
105
|
-
return this.luxonDateTime.month;
|
|
106
|
-
}
|
|
107
|
-
get day() {
|
|
108
|
-
return this.luxonDateTime.day;
|
|
109
|
-
}
|
|
110
|
-
startOf(period) {
|
|
111
|
-
return new CalendarDate(this.luxonDateTime.startOf(period));
|
|
112
|
-
}
|
|
113
|
-
endOf(period) {
|
|
114
|
-
return new CalendarDate(this.luxonDateTime.endOf(period));
|
|
115
|
-
}
|
|
116
|
-
plus(duration) {
|
|
117
|
-
return new CalendarDate(this.luxonDateTime.plus(duration));
|
|
118
|
-
}
|
|
119
|
-
minus(duration) {
|
|
120
|
-
return new CalendarDate(this.luxonDateTime.minus(duration));
|
|
121
|
-
}
|
|
122
|
-
static max(...calendarDates) {
|
|
123
|
-
const dateTimes = calendarDates.map(calendarDate => calendarDate.toDateTime());
|
|
124
|
-
return new CalendarDate(DateTime.max(...dateTimes));
|
|
125
|
-
}
|
|
126
|
-
static min(...calendarDates) {
|
|
127
|
-
const dateTimes = calendarDates.map(calendarDate => calendarDate.toDateTime());
|
|
128
|
-
return new CalendarDate(DateTime.min(...dateTimes));
|
|
129
|
-
}
|
|
130
|
-
hasSame(otherCalendarDate, period) {
|
|
131
|
-
const otherDateTime = otherCalendarDate.toDateTime();
|
|
132
|
-
if (otherDateTime === null)
|
|
133
|
-
return false;
|
|
134
|
-
return this.luxonDateTime.hasSame(otherDateTime, period);
|
|
135
|
-
}
|
|
136
|
-
diff(otherCalendarDate, duration) {
|
|
137
|
-
const otherDateTime = otherCalendarDate.toDateTime();
|
|
138
|
-
return this.luxonDateTime.diff(otherDateTime, duration)[duration];
|
|
139
|
-
}
|
|
140
|
-
diffNow(duration) {
|
|
141
|
-
return Math.ceil(this.luxonDateTime.diffNow(duration)[duration]);
|
|
142
|
-
}
|
|
143
|
-
equals(otherCalendarDate) {
|
|
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'));
|
|
150
|
-
}
|
|
151
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { DateObjectUnits, DateTimeJSOptions, DateTimeUnit, LocaleOptions } from '../types/luxon/datetime.js';
|
|
2
|
-
import { DurationLikeObject, DurationObjectUnits } from '../types/luxon/duration.js';
|
|
3
|
-
import { DateTimeFormatOptions } from '../types/luxon/misc.js';
|
|
4
|
-
import { Zone } from '../types/luxon/zone.js';
|
|
5
|
-
import { DateTime } from './DateTime.js';
|
|
6
|
-
type CalendarDateDurationLike = Pick<DurationLikeObject, 'year' | 'years' | 'quarter' | 'quarters' | 'month' | 'months' | 'week' | 'weeks' | 'day' | 'days'>;
|
|
7
|
-
type CalendarDateDurationUnit = keyof Pick<DurationObjectUnits, 'years' | 'quarters' | 'months' | 'weeks' | 'days'>;
|
|
8
|
-
type CalendarDateUnit = Extract<DateTimeUnit, 'year' | 'quarter' | 'month' | 'week' | 'day'>;
|
|
9
|
-
export default class CalendarDate {
|
|
10
|
-
private readonly luxonDateTime;
|
|
11
|
-
constructor(source?: DateTime | number | null, month?: number, day?: number);
|
|
12
|
-
static fromDateTime(dateTime: DateTime): CalendarDate;
|
|
13
|
-
static fromJSDate(javascriptDate: Date, { zone }?: {
|
|
14
|
-
zone?: string | Zone;
|
|
15
|
-
}): CalendarDate;
|
|
16
|
-
static fromISO(str: string, { zone }?: {
|
|
17
|
-
zone?: string | Zone;
|
|
18
|
-
}): CalendarDate;
|
|
19
|
-
static fromSQL(str: string): CalendarDate;
|
|
20
|
-
static fromObject(obj: DateObjectUnits, opts?: DateTimeJSOptions): CalendarDate;
|
|
21
|
-
static today({ zone }?: {
|
|
22
|
-
zone?: string | Zone;
|
|
23
|
-
}): CalendarDate;
|
|
24
|
-
static tomorrow(options?: {
|
|
25
|
-
zone?: string | Zone;
|
|
26
|
-
}): CalendarDate;
|
|
27
|
-
static yesterday(options?: {
|
|
28
|
-
zone?: string | Zone;
|
|
29
|
-
}): CalendarDate;
|
|
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;
|
|
42
|
-
startOf(period: CalendarDateUnit): CalendarDate;
|
|
43
|
-
endOf(period: CalendarDateUnit): CalendarDate;
|
|
44
|
-
plus(duration: CalendarDateDurationLike): CalendarDate;
|
|
45
|
-
minus(duration: CalendarDateDurationLike): CalendarDate;
|
|
46
|
-
static max(...calendarDates: Array<CalendarDate>): CalendarDate;
|
|
47
|
-
static min(...calendarDates: Array<CalendarDate>): CalendarDate;
|
|
48
|
-
hasSame(otherCalendarDate: CalendarDate, period: CalendarDateUnit): boolean;
|
|
49
|
-
diff(otherCalendarDate: CalendarDate, duration: CalendarDateDurationUnit): number;
|
|
50
|
-
diffNow(duration: CalendarDateDurationUnit): number;
|
|
51
|
-
equals(otherCalendarDate: CalendarDate): boolean;
|
|
52
|
-
}
|
|
53
|
-
export declare class InvalidCalendarDate extends Error {
|
|
54
|
-
constructor(error: Error);
|
|
55
|
-
}
|
|
56
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { DateTime as LuxonDateTime } from '../types/luxon/datetime.js';
|
|
2
|
-
import { Settings as LuxonSettings } from '../types/luxon/settings.js';
|
|
3
|
-
export declare const DateTime: typeof LuxonDateTime;
|
|
4
|
-
export type DateTime = LuxonDateTime;
|
|
5
|
-
export declare const Settings: typeof LuxonSettings;
|
|
6
|
-
export type Settings = LuxonSettings;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { TSSettings } from './settings.js'
|
|
2
|
-
|
|
3
|
-
export type CanBeInvalid = TSSettings extends { throwOnInvalid: true } ? false : true
|
|
4
|
-
|
|
5
|
-
export type DefaultValidity = CanBeInvalid extends true ? boolean : true
|
|
6
|
-
|
|
7
|
-
export type IfValid<
|
|
8
|
-
ValidType,
|
|
9
|
-
InvalidType,
|
|
10
|
-
ThisIsValid extends boolean | undefined,
|
|
11
|
-
> = ThisIsValid extends true
|
|
12
|
-
? ValidType
|
|
13
|
-
: ThisIsValid extends false
|
|
14
|
-
? InvalidType
|
|
15
|
-
: CanBeInvalid extends true
|
|
16
|
-
? ValidType | InvalidType
|
|
17
|
-
: ValidType
|
|
18
|
-
|
|
19
|
-
export type Valid = true
|
|
20
|
-
export type Invalid = false
|