@rvoh/dream 2.3.0-alpha.1 → 2.3.0-alpha.3

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.
Files changed (186) hide show
  1. package/dist/cjs/src/utils/datetime/DateTime.js +221 -0
  2. package/dist/esm/src/utils/datetime/DateTime.js +221 -0
  3. package/dist/types/src/types/datetime.d.ts +0 -3
  4. package/dist/types/src/types/datetime.ts +0 -4
  5. package/dist/types/src/utils/datetime/CalendarDate.d.ts +2 -2
  6. package/dist/types/src/utils/datetime/DateTime.d.ts +178 -2
  7. package/docs/assets/search.js +1 -1
  8. package/docs/classes/db.DreamMigrationHelpers.html +9 -9
  9. package/docs/classes/db.KyselyQueryDriver.html +32 -32
  10. package/docs/classes/db.PostgresQueryDriver.html +33 -33
  11. package/docs/classes/db.QueryDriverBase.html +31 -31
  12. package/docs/classes/errors.CheckConstraintViolation.html +3 -3
  13. package/docs/classes/errors.ColumnOverflow.html +3 -3
  14. package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +3 -3
  15. package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +3 -3
  16. package/docs/classes/errors.DataTypeColumnTypeMismatch.html +3 -3
  17. package/docs/classes/errors.GlobalNameNotSet.html +3 -3
  18. package/docs/classes/errors.InvalidCalendarDate.html +2 -2
  19. package/docs/classes/errors.InvalidDateTime.html +2 -2
  20. package/docs/classes/errors.MissingSerializersDefinition.html +3 -3
  21. package/docs/classes/errors.NonLoadedAssociation.html +3 -3
  22. package/docs/classes/errors.NotNullViolation.html +3 -3
  23. package/docs/classes/errors.RecordNotFound.html +3 -3
  24. package/docs/classes/errors.ValidationError.html +3 -3
  25. package/docs/classes/index.CalendarDate.html +33 -33
  26. package/docs/classes/index.DateTime.html +202 -92
  27. package/docs/classes/index.Decorators.html +19 -19
  28. package/docs/classes/index.Dream.html +116 -116
  29. package/docs/classes/index.DreamApp.html +5 -5
  30. package/docs/classes/index.DreamTransaction.html +2 -2
  31. package/docs/classes/index.Env.html +2 -2
  32. package/docs/classes/index.Query.html +56 -56
  33. package/docs/classes/system.CliFileWriter.html +2 -2
  34. package/docs/classes/system.DreamBin.html +2 -2
  35. package/docs/classes/system.DreamCLI.html +5 -5
  36. package/docs/classes/system.DreamImporter.html +2 -2
  37. package/docs/classes/system.DreamLogos.html +2 -2
  38. package/docs/classes/system.DreamSerializerBuilder.html +8 -8
  39. package/docs/classes/system.ObjectSerializerBuilder.html +8 -8
  40. package/docs/classes/system.PathHelpers.html +3 -3
  41. package/docs/classes/utils.Encrypt.html +2 -2
  42. package/docs/classes/utils.Range.html +2 -2
  43. package/docs/functions/db.closeAllDbConnections.html +1 -1
  44. package/docs/functions/db.dreamDbConnections.html +1 -1
  45. package/docs/functions/db.untypedDb.html +1 -1
  46. package/docs/functions/db.validateColumn.html +1 -1
  47. package/docs/functions/db.validateTable.html +1 -1
  48. package/docs/functions/errors.pgErrorType.html +1 -1
  49. package/docs/functions/index.DreamSerializer.html +1 -1
  50. package/docs/functions/index.ObjectSerializer.html +1 -1
  51. package/docs/functions/index.ReplicaSafe.html +1 -1
  52. package/docs/functions/index.STI.html +1 -1
  53. package/docs/functions/index.SoftDelete.html +1 -1
  54. package/docs/functions/utils.camelize.html +1 -1
  55. package/docs/functions/utils.capitalize.html +1 -1
  56. package/docs/functions/utils.cloneDeepSafe.html +1 -1
  57. package/docs/functions/utils.compact.html +1 -1
  58. package/docs/functions/utils.groupBy.html +1 -1
  59. package/docs/functions/utils.hyphenize.html +1 -1
  60. package/docs/functions/utils.intersection.html +1 -1
  61. package/docs/functions/utils.isEmpty.html +1 -1
  62. package/docs/functions/utils.normalizeUnicode.html +1 -1
  63. package/docs/functions/utils.pascalize.html +1 -1
  64. package/docs/functions/utils.percent.html +1 -1
  65. package/docs/functions/utils.range-1.html +1 -1
  66. package/docs/functions/utils.round.html +1 -1
  67. package/docs/functions/utils.sanitizeString.html +1 -1
  68. package/docs/functions/utils.snakeify.html +1 -1
  69. package/docs/functions/utils.sort.html +1 -1
  70. package/docs/functions/utils.sortBy.html +1 -1
  71. package/docs/functions/utils.sortObjectByKey.html +1 -1
  72. package/docs/functions/utils.sortObjectByValue.html +1 -1
  73. package/docs/functions/utils.uncapitalize.html +1 -1
  74. package/docs/functions/utils.uniq.html +1 -1
  75. package/docs/interfaces/openapi.OpenapiDescription.html +2 -2
  76. package/docs/interfaces/openapi.OpenapiSchemaProperties.html +1 -1
  77. package/docs/interfaces/openapi.OpenapiSchemaPropertiesShorthand.html +1 -1
  78. package/docs/interfaces/openapi.OpenapiTypeFieldObject.html +1 -1
  79. package/docs/interfaces/types.BelongsToStatement.html +2 -2
  80. package/docs/interfaces/types.DecoratorContext.html +2 -2
  81. package/docs/interfaces/types.DreamAppInitOptions.html +2 -2
  82. package/docs/interfaces/types.DreamAppOpts.html +2 -2
  83. package/docs/interfaces/types.DurationObject.html +2 -2
  84. package/docs/interfaces/types.EncryptOptions.html +2 -2
  85. package/docs/interfaces/types.InternalAnyTypedSerializerRendersMany.html +2 -2
  86. package/docs/interfaces/types.InternalAnyTypedSerializerRendersOne.html +2 -2
  87. package/docs/interfaces/types.SerializerRendererOpts.html +2 -2
  88. package/docs/modules/db.html +1 -1
  89. package/docs/modules/errors.html +1 -1
  90. package/docs/modules/index.html +1 -1
  91. package/docs/modules/openapi.html +1 -1
  92. package/docs/modules/system.html +1 -1
  93. package/docs/modules/types.html +1 -1
  94. package/docs/modules/utils.html +1 -1
  95. package/docs/types/openapi.CommonOpenapiSchemaObjectFields.html +1 -1
  96. package/docs/types/openapi.OpenapiAllTypes.html +1 -1
  97. package/docs/types/openapi.OpenapiFormats.html +1 -1
  98. package/docs/types/openapi.OpenapiNumberFormats.html +1 -1
  99. package/docs/types/openapi.OpenapiPrimitiveBaseTypes.html +1 -1
  100. package/docs/types/openapi.OpenapiPrimitiveTypes.html +1 -1
  101. package/docs/types/openapi.OpenapiSchemaArray.html +1 -1
  102. package/docs/types/openapi.OpenapiSchemaArrayShorthand.html +1 -1
  103. package/docs/types/openapi.OpenapiSchemaBase.html +1 -1
  104. package/docs/types/openapi.OpenapiSchemaBody.html +1 -1
  105. package/docs/types/openapi.OpenapiSchemaBodyShorthand.html +1 -1
  106. package/docs/types/openapi.OpenapiSchemaCommonFields.html +1 -1
  107. package/docs/types/openapi.OpenapiSchemaExpressionAllOf.html +1 -1
  108. package/docs/types/openapi.OpenapiSchemaExpressionAnyOf.html +1 -1
  109. package/docs/types/openapi.OpenapiSchemaExpressionOneOf.html +1 -1
  110. package/docs/types/openapi.OpenapiSchemaExpressionRef.html +1 -1
  111. package/docs/types/openapi.OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  112. package/docs/types/openapi.OpenapiSchemaInteger.html +1 -1
  113. package/docs/types/openapi.OpenapiSchemaNull.html +1 -1
  114. package/docs/types/openapi.OpenapiSchemaNumber.html +1 -1
  115. package/docs/types/openapi.OpenapiSchemaObject.html +1 -1
  116. package/docs/types/openapi.OpenapiSchemaObjectAllOf.html +1 -1
  117. package/docs/types/openapi.OpenapiSchemaObjectAllOfShorthand.html +1 -1
  118. package/docs/types/openapi.OpenapiSchemaObjectAnyOf.html +1 -1
  119. package/docs/types/openapi.OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  120. package/docs/types/openapi.OpenapiSchemaObjectBase.html +1 -1
  121. package/docs/types/openapi.OpenapiSchemaObjectBaseShorthand.html +1 -1
  122. package/docs/types/openapi.OpenapiSchemaObjectOneOf.html +1 -1
  123. package/docs/types/openapi.OpenapiSchemaObjectOneOfShorthand.html +1 -1
  124. package/docs/types/openapi.OpenapiSchemaObjectShorthand.html +1 -1
  125. package/docs/types/openapi.OpenapiSchemaPrimitiveGeneric.html +1 -1
  126. package/docs/types/openapi.OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  127. package/docs/types/openapi.OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  128. package/docs/types/openapi.OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  129. package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  130. package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  131. package/docs/types/openapi.OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  132. package/docs/types/openapi.OpenapiSchemaString.html +1 -1
  133. package/docs/types/openapi.OpenapiShorthandAllTypes.html +1 -1
  134. package/docs/types/openapi.OpenapiShorthandPrimitiveBaseTypes.html +1 -1
  135. package/docs/types/openapi.OpenapiShorthandPrimitiveTypes.html +1 -1
  136. package/docs/types/openapi.OpenapiTypeField.html +1 -1
  137. package/docs/types/system.DreamAppAllowedPackageManagersEnum.html +1 -1
  138. package/docs/types/types.CalendarDateDurationUnit.html +1 -1
  139. package/docs/types/types.Camelized.html +1 -1
  140. package/docs/types/types.DbConnectionType.html +1 -1
  141. package/docs/types/types.DbTypes.html +1 -1
  142. package/docs/types/types.DreamAssociationMetadata.html +1 -1
  143. package/docs/types/types.DreamAttributes.html +1 -1
  144. package/docs/types/types.DreamClassAssociationAndStatement.html +1 -1
  145. package/docs/types/types.DreamClassColumn.html +1 -1
  146. package/docs/types/types.DreamColumn.html +1 -1
  147. package/docs/types/types.DreamColumnNames.html +1 -1
  148. package/docs/types/types.DreamLogLevel.html +1 -1
  149. package/docs/types/types.DreamLogger.html +1 -1
  150. package/docs/types/types.DreamModelSerializerType.html +1 -1
  151. package/docs/types/types.DreamOrViewModelClassSerializerKey.html +1 -1
  152. package/docs/types/types.DreamOrViewModelSerializerKey.html +1 -1
  153. package/docs/types/types.DreamParamSafeAttributes.html +1 -1
  154. package/docs/types/types.DreamParamSafeColumnNames.html +1 -1
  155. package/docs/types/types.DreamSerializable.html +1 -1
  156. package/docs/types/types.DreamSerializableArray.html +1 -1
  157. package/docs/types/types.DreamSerializerKey.html +1 -1
  158. package/docs/types/types.DreamSerializers.html +1 -1
  159. package/docs/types/types.DreamVirtualColumns.html +1 -1
  160. package/docs/types/types.DurationUnit.html +1 -1
  161. package/docs/types/types.EncryptAlgorithm.html +1 -1
  162. package/docs/types/types.HasManyStatement.html +1 -1
  163. package/docs/types/types.HasOneStatement.html +1 -1
  164. package/docs/types/types.Hyphenized.html +1 -1
  165. package/docs/types/types.Pascalized.html +1 -1
  166. package/docs/types/types.PrimaryKeyType.html +1 -1
  167. package/docs/types/types.RoundingPrecision.html +1 -1
  168. package/docs/types/types.SerializerCasing.html +1 -1
  169. package/docs/types/types.SimpleObjectSerializerType.html +1 -1
  170. package/docs/types/types.Snakeified.html +1 -1
  171. package/docs/types/types.StrictInterface.html +1 -1
  172. package/docs/types/types.UpdateableAssociationProperties.html +1 -1
  173. package/docs/types/types.UpdateableProperties.html +1 -1
  174. package/docs/types/types.ValidationType.html +1 -1
  175. package/docs/types/types.ViewModel.html +1 -1
  176. package/docs/types/types.ViewModelClass.html +1 -1
  177. package/docs/types/types.WeekdayName.html +1 -1
  178. package/docs/types/types.WhereStatementForDream.html +1 -1
  179. package/docs/types/types.WhereStatementForDreamClass.html +1 -1
  180. package/docs/variables/index.DreamConst.html +1 -1
  181. package/docs/variables/index.ops.html +1 -1
  182. package/docs/variables/openapi.openapiPrimitiveTypes-1.html +1 -1
  183. package/docs/variables/openapi.openapiShorthandPrimitiveTypes-1.html +1 -1
  184. package/docs/variables/system.DreamAppAllowedPackageManagersEnumValues.html +1 -1
  185. package/docs/variables/system.primaryKeyTypes.html +1 -1
  186. package/package.json +1 -1
@@ -131,6 +131,227 @@ export class DateTime {
131
131
  static now() {
132
132
  return new DateTime(LuxonDateTime.now(), 0);
133
133
  }
134
+ // Format presets for toLocaleString()
135
+ /**
136
+ * {@link DateTime.toLocaleString} format like 10/14/1983
137
+ * @example
138
+ * ```ts
139
+ * DateTime.now().toLocaleString(DateTime.DATE_SHORT)
140
+ * ```
141
+ */
142
+ static get DATE_SHORT() {
143
+ return LuxonDateTime.DATE_SHORT;
144
+ }
145
+ /**
146
+ * {@link DateTime.toLocaleString} format like 'Oct 14, 1983'
147
+ * @example
148
+ * ```ts
149
+ * DateTime.now().toLocaleString(DateTime.DATE_MED)
150
+ * ```
151
+ */
152
+ static get DATE_MED() {
153
+ return LuxonDateTime.DATE_MED;
154
+ }
155
+ /**
156
+ * {@link DateTime.toLocaleString} format like 'Fri, Oct 14, 1983'
157
+ * @example
158
+ * ```ts
159
+ * DateTime.now().toLocaleString(DateTime.DATE_MED_WITH_WEEKDAY)
160
+ * ```
161
+ */
162
+ static get DATE_MED_WITH_WEEKDAY() {
163
+ return LuxonDateTime.DATE_MED_WITH_WEEKDAY;
164
+ }
165
+ /**
166
+ * {@link DateTime.toLocaleString} format like 'October 14, 1983'
167
+ * @example
168
+ * ```ts
169
+ * DateTime.now().toLocaleString(DateTime.DATE_FULL)
170
+ * ```
171
+ */
172
+ static get DATE_FULL() {
173
+ return LuxonDateTime.DATE_FULL;
174
+ }
175
+ /**
176
+ * {@link DateTime.toLocaleString} format like 'Tuesday, October 14, 1983'
177
+ * @example
178
+ * ```ts
179
+ * DateTime.now().toLocaleString(DateTime.DATE_HUGE)
180
+ * ```
181
+ */
182
+ static get DATE_HUGE() {
183
+ return LuxonDateTime.DATE_HUGE;
184
+ }
185
+ /**
186
+ * {@link DateTime.toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is.
187
+ * @example
188
+ * ```ts
189
+ * DateTime.now().toLocaleString(DateTime.TIME_SIMPLE)
190
+ * ```
191
+ */
192
+ static get TIME_SIMPLE() {
193
+ return LuxonDateTime.TIME_SIMPLE;
194
+ }
195
+ /**
196
+ * {@link DateTime.toLocaleString} format like '09:30:23 AM'. Only 12-hour if the locale is.
197
+ * @example
198
+ * ```ts
199
+ * DateTime.now().toLocaleString(DateTime.TIME_WITH_SECONDS)
200
+ * ```
201
+ */
202
+ static get TIME_WITH_SECONDS() {
203
+ return LuxonDateTime.TIME_WITH_SECONDS;
204
+ }
205
+ /**
206
+ * {@link DateTime.toLocaleString} format like '09:30:23 AM EDT'. Only 12-hour if the locale is.
207
+ * @example
208
+ * ```ts
209
+ * DateTime.now().toLocaleString(DateTime.TIME_WITH_SHORT_OFFSET)
210
+ * ```
211
+ */
212
+ static get TIME_WITH_SHORT_OFFSET() {
213
+ return LuxonDateTime.TIME_WITH_SHORT_OFFSET;
214
+ }
215
+ /**
216
+ * {@link DateTime.toLocaleString} format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is.
217
+ * @example
218
+ * ```ts
219
+ * DateTime.now().toLocaleString(DateTime.TIME_WITH_LONG_OFFSET)
220
+ * ```
221
+ */
222
+ static get TIME_WITH_LONG_OFFSET() {
223
+ return LuxonDateTime.TIME_WITH_LONG_OFFSET;
224
+ }
225
+ /**
226
+ * {@link DateTime.toLocaleString} format like '09:30', always 24-hour.
227
+ * @example
228
+ * ```ts
229
+ * DateTime.now().toLocaleString(DateTime.TIME_24_SIMPLE)
230
+ * ```
231
+ */
232
+ static get TIME_24_SIMPLE() {
233
+ return LuxonDateTime.TIME_24_SIMPLE;
234
+ }
235
+ /**
236
+ * {@link DateTime.toLocaleString} format like '09:30:23', always 24-hour.
237
+ * @example
238
+ * ```ts
239
+ * DateTime.now().toLocaleString(DateTime.TIME_24_WITH_SECONDS)
240
+ * ```
241
+ */
242
+ static get TIME_24_WITH_SECONDS() {
243
+ return LuxonDateTime.TIME_24_WITH_SECONDS;
244
+ }
245
+ /**
246
+ * {@link DateTime.toLocaleString} format like '09:30:23 EDT', always 24-hour.
247
+ * @example
248
+ * ```ts
249
+ * DateTime.now().toLocaleString(DateTime.TIME_24_WITH_SHORT_OFFSET)
250
+ * ```
251
+ */
252
+ static get TIME_24_WITH_SHORT_OFFSET() {
253
+ return LuxonDateTime.TIME_24_WITH_SHORT_OFFSET;
254
+ }
255
+ /**
256
+ * {@link DateTime.toLocaleString} format like '09:30:23 Eastern Daylight Time', always 24-hour.
257
+ * @example
258
+ * ```ts
259
+ * DateTime.now().toLocaleString(DateTime.TIME_24_WITH_LONG_OFFSET)
260
+ * ```
261
+ */
262
+ static get TIME_24_WITH_LONG_OFFSET() {
263
+ return LuxonDateTime.TIME_24_WITH_LONG_OFFSET;
264
+ }
265
+ /**
266
+ * {@link DateTime.toLocaleString} format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.
267
+ * @example
268
+ * ```ts
269
+ * DateTime.now().toLocaleString(DateTime.DATETIME_SHORT)
270
+ * ```
271
+ */
272
+ static get DATETIME_SHORT() {
273
+ return LuxonDateTime.DATETIME_SHORT;
274
+ }
275
+ /**
276
+ * {@link DateTime.toLocaleString} format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.
277
+ * @example
278
+ * ```ts
279
+ * DateTime.now().toLocaleString(DateTime.DATETIME_SHORT_WITH_SECONDS)
280
+ * ```
281
+ */
282
+ static get DATETIME_SHORT_WITH_SECONDS() {
283
+ return LuxonDateTime.DATETIME_SHORT_WITH_SECONDS;
284
+ }
285
+ /**
286
+ * {@link DateTime.toLocaleString} format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is.
287
+ * @example
288
+ * ```ts
289
+ * DateTime.now().toLocaleString(DateTime.DATETIME_MED)
290
+ * ```
291
+ */
292
+ static get DATETIME_MED() {
293
+ return LuxonDateTime.DATETIME_MED;
294
+ }
295
+ /**
296
+ * {@link DateTime.toLocaleString} format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is.
297
+ * @example
298
+ * ```ts
299
+ * DateTime.now().toLocaleString(DateTime.DATETIME_MED_WITH_SECONDS)
300
+ * ```
301
+ */
302
+ static get DATETIME_MED_WITH_SECONDS() {
303
+ return LuxonDateTime.DATETIME_MED_WITH_SECONDS;
304
+ }
305
+ /**
306
+ * {@link DateTime.toLocaleString} format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is.
307
+ * @example
308
+ * ```ts
309
+ * DateTime.now().toLocaleString(DateTime.DATETIME_MED_WITH_WEEKDAY)
310
+ * ```
311
+ */
312
+ static get DATETIME_MED_WITH_WEEKDAY() {
313
+ return LuxonDateTime.DATETIME_MED_WITH_WEEKDAY;
314
+ }
315
+ /**
316
+ * {@link DateTime.toLocaleString} format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is.
317
+ * @example
318
+ * ```ts
319
+ * DateTime.now().toLocaleString(DateTime.DATETIME_FULL)
320
+ * ```
321
+ */
322
+ static get DATETIME_FULL() {
323
+ return LuxonDateTime.DATETIME_FULL;
324
+ }
325
+ /**
326
+ * {@link DateTime.toLocaleString} format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is.
327
+ * @example
328
+ * ```ts
329
+ * DateTime.now().toLocaleString(DateTime.DATETIME_FULL_WITH_SECONDS)
330
+ * ```
331
+ */
332
+ static get DATETIME_FULL_WITH_SECONDS() {
333
+ return LuxonDateTime.DATETIME_FULL_WITH_SECONDS;
334
+ }
335
+ /**
336
+ * {@link DateTime.toLocaleString} format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is.
337
+ * @example
338
+ * ```ts
339
+ * DateTime.now().toLocaleString(DateTime.DATETIME_HUGE)
340
+ * ```
341
+ */
342
+ static get DATETIME_HUGE() {
343
+ return LuxonDateTime.DATETIME_HUGE;
344
+ }
345
+ /**
346
+ * {@link DateTime.toLocaleString} format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is.
347
+ * @example
348
+ * ```ts
349
+ * DateTime.now().toLocaleString(DateTime.DATETIME_HUGE_WITH_SECONDS)
350
+ * ```
351
+ */
352
+ static get DATETIME_HUGE_WITH_SECONDS() {
353
+ return LuxonDateTime.DATETIME_HUGE_WITH_SECONDS;
354
+ }
134
355
  static local(yearOrOpts, month, day, hour, minute, second, millisecond, microsecondOrOpts, opts) {
135
356
  const isOpts = (v) => typeof v === 'object' && v !== null;
136
357
  const { luxonDatetime, microseconds } = buildLocalOrUtcDateTime(yearOrOpts, month, day, hour, minute, second, millisecond, microsecondOrOpts, opts, isOpts, (y, m, d, h, mi, s, ms, options) => LuxonDateTime.local(y, m, d, h, mi, s, ms, options));
@@ -131,6 +131,227 @@ export class DateTime {
131
131
  static now() {
132
132
  return new DateTime(LuxonDateTime.now(), 0);
133
133
  }
134
+ // Format presets for toLocaleString()
135
+ /**
136
+ * {@link DateTime.toLocaleString} format like 10/14/1983
137
+ * @example
138
+ * ```ts
139
+ * DateTime.now().toLocaleString(DateTime.DATE_SHORT)
140
+ * ```
141
+ */
142
+ static get DATE_SHORT() {
143
+ return LuxonDateTime.DATE_SHORT;
144
+ }
145
+ /**
146
+ * {@link DateTime.toLocaleString} format like 'Oct 14, 1983'
147
+ * @example
148
+ * ```ts
149
+ * DateTime.now().toLocaleString(DateTime.DATE_MED)
150
+ * ```
151
+ */
152
+ static get DATE_MED() {
153
+ return LuxonDateTime.DATE_MED;
154
+ }
155
+ /**
156
+ * {@link DateTime.toLocaleString} format like 'Fri, Oct 14, 1983'
157
+ * @example
158
+ * ```ts
159
+ * DateTime.now().toLocaleString(DateTime.DATE_MED_WITH_WEEKDAY)
160
+ * ```
161
+ */
162
+ static get DATE_MED_WITH_WEEKDAY() {
163
+ return LuxonDateTime.DATE_MED_WITH_WEEKDAY;
164
+ }
165
+ /**
166
+ * {@link DateTime.toLocaleString} format like 'October 14, 1983'
167
+ * @example
168
+ * ```ts
169
+ * DateTime.now().toLocaleString(DateTime.DATE_FULL)
170
+ * ```
171
+ */
172
+ static get DATE_FULL() {
173
+ return LuxonDateTime.DATE_FULL;
174
+ }
175
+ /**
176
+ * {@link DateTime.toLocaleString} format like 'Tuesday, October 14, 1983'
177
+ * @example
178
+ * ```ts
179
+ * DateTime.now().toLocaleString(DateTime.DATE_HUGE)
180
+ * ```
181
+ */
182
+ static get DATE_HUGE() {
183
+ return LuxonDateTime.DATE_HUGE;
184
+ }
185
+ /**
186
+ * {@link DateTime.toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is.
187
+ * @example
188
+ * ```ts
189
+ * DateTime.now().toLocaleString(DateTime.TIME_SIMPLE)
190
+ * ```
191
+ */
192
+ static get TIME_SIMPLE() {
193
+ return LuxonDateTime.TIME_SIMPLE;
194
+ }
195
+ /**
196
+ * {@link DateTime.toLocaleString} format like '09:30:23 AM'. Only 12-hour if the locale is.
197
+ * @example
198
+ * ```ts
199
+ * DateTime.now().toLocaleString(DateTime.TIME_WITH_SECONDS)
200
+ * ```
201
+ */
202
+ static get TIME_WITH_SECONDS() {
203
+ return LuxonDateTime.TIME_WITH_SECONDS;
204
+ }
205
+ /**
206
+ * {@link DateTime.toLocaleString} format like '09:30:23 AM EDT'. Only 12-hour if the locale is.
207
+ * @example
208
+ * ```ts
209
+ * DateTime.now().toLocaleString(DateTime.TIME_WITH_SHORT_OFFSET)
210
+ * ```
211
+ */
212
+ static get TIME_WITH_SHORT_OFFSET() {
213
+ return LuxonDateTime.TIME_WITH_SHORT_OFFSET;
214
+ }
215
+ /**
216
+ * {@link DateTime.toLocaleString} format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is.
217
+ * @example
218
+ * ```ts
219
+ * DateTime.now().toLocaleString(DateTime.TIME_WITH_LONG_OFFSET)
220
+ * ```
221
+ */
222
+ static get TIME_WITH_LONG_OFFSET() {
223
+ return LuxonDateTime.TIME_WITH_LONG_OFFSET;
224
+ }
225
+ /**
226
+ * {@link DateTime.toLocaleString} format like '09:30', always 24-hour.
227
+ * @example
228
+ * ```ts
229
+ * DateTime.now().toLocaleString(DateTime.TIME_24_SIMPLE)
230
+ * ```
231
+ */
232
+ static get TIME_24_SIMPLE() {
233
+ return LuxonDateTime.TIME_24_SIMPLE;
234
+ }
235
+ /**
236
+ * {@link DateTime.toLocaleString} format like '09:30:23', always 24-hour.
237
+ * @example
238
+ * ```ts
239
+ * DateTime.now().toLocaleString(DateTime.TIME_24_WITH_SECONDS)
240
+ * ```
241
+ */
242
+ static get TIME_24_WITH_SECONDS() {
243
+ return LuxonDateTime.TIME_24_WITH_SECONDS;
244
+ }
245
+ /**
246
+ * {@link DateTime.toLocaleString} format like '09:30:23 EDT', always 24-hour.
247
+ * @example
248
+ * ```ts
249
+ * DateTime.now().toLocaleString(DateTime.TIME_24_WITH_SHORT_OFFSET)
250
+ * ```
251
+ */
252
+ static get TIME_24_WITH_SHORT_OFFSET() {
253
+ return LuxonDateTime.TIME_24_WITH_SHORT_OFFSET;
254
+ }
255
+ /**
256
+ * {@link DateTime.toLocaleString} format like '09:30:23 Eastern Daylight Time', always 24-hour.
257
+ * @example
258
+ * ```ts
259
+ * DateTime.now().toLocaleString(DateTime.TIME_24_WITH_LONG_OFFSET)
260
+ * ```
261
+ */
262
+ static get TIME_24_WITH_LONG_OFFSET() {
263
+ return LuxonDateTime.TIME_24_WITH_LONG_OFFSET;
264
+ }
265
+ /**
266
+ * {@link DateTime.toLocaleString} format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.
267
+ * @example
268
+ * ```ts
269
+ * DateTime.now().toLocaleString(DateTime.DATETIME_SHORT)
270
+ * ```
271
+ */
272
+ static get DATETIME_SHORT() {
273
+ return LuxonDateTime.DATETIME_SHORT;
274
+ }
275
+ /**
276
+ * {@link DateTime.toLocaleString} format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.
277
+ * @example
278
+ * ```ts
279
+ * DateTime.now().toLocaleString(DateTime.DATETIME_SHORT_WITH_SECONDS)
280
+ * ```
281
+ */
282
+ static get DATETIME_SHORT_WITH_SECONDS() {
283
+ return LuxonDateTime.DATETIME_SHORT_WITH_SECONDS;
284
+ }
285
+ /**
286
+ * {@link DateTime.toLocaleString} format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is.
287
+ * @example
288
+ * ```ts
289
+ * DateTime.now().toLocaleString(DateTime.DATETIME_MED)
290
+ * ```
291
+ */
292
+ static get DATETIME_MED() {
293
+ return LuxonDateTime.DATETIME_MED;
294
+ }
295
+ /**
296
+ * {@link DateTime.toLocaleString} format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is.
297
+ * @example
298
+ * ```ts
299
+ * DateTime.now().toLocaleString(DateTime.DATETIME_MED_WITH_SECONDS)
300
+ * ```
301
+ */
302
+ static get DATETIME_MED_WITH_SECONDS() {
303
+ return LuxonDateTime.DATETIME_MED_WITH_SECONDS;
304
+ }
305
+ /**
306
+ * {@link DateTime.toLocaleString} format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is.
307
+ * @example
308
+ * ```ts
309
+ * DateTime.now().toLocaleString(DateTime.DATETIME_MED_WITH_WEEKDAY)
310
+ * ```
311
+ */
312
+ static get DATETIME_MED_WITH_WEEKDAY() {
313
+ return LuxonDateTime.DATETIME_MED_WITH_WEEKDAY;
314
+ }
315
+ /**
316
+ * {@link DateTime.toLocaleString} format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is.
317
+ * @example
318
+ * ```ts
319
+ * DateTime.now().toLocaleString(DateTime.DATETIME_FULL)
320
+ * ```
321
+ */
322
+ static get DATETIME_FULL() {
323
+ return LuxonDateTime.DATETIME_FULL;
324
+ }
325
+ /**
326
+ * {@link DateTime.toLocaleString} format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is.
327
+ * @example
328
+ * ```ts
329
+ * DateTime.now().toLocaleString(DateTime.DATETIME_FULL_WITH_SECONDS)
330
+ * ```
331
+ */
332
+ static get DATETIME_FULL_WITH_SECONDS() {
333
+ return LuxonDateTime.DATETIME_FULL_WITH_SECONDS;
334
+ }
335
+ /**
336
+ * {@link DateTime.toLocaleString} format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is.
337
+ * @example
338
+ * ```ts
339
+ * DateTime.now().toLocaleString(DateTime.DATETIME_HUGE)
340
+ * ```
341
+ */
342
+ static get DATETIME_HUGE() {
343
+ return LuxonDateTime.DATETIME_HUGE;
344
+ }
345
+ /**
346
+ * {@link DateTime.toLocaleString} format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is.
347
+ * @example
348
+ * ```ts
349
+ * DateTime.now().toLocaleString(DateTime.DATETIME_HUGE_WITH_SECONDS)
350
+ * ```
351
+ */
352
+ static get DATETIME_HUGE_WITH_SECONDS() {
353
+ return LuxonDateTime.DATETIME_HUGE_WITH_SECONDS;
354
+ }
134
355
  static local(yearOrOpts, month, day, hour, minute, second, millisecond, microsecondOrOpts, opts) {
135
356
  const isOpts = (v) => typeof v === 'object' && v !== null;
136
357
  const { luxonDatetime, microseconds } = buildLocalOrUtcDateTime(yearOrOpts, month, day, hour, minute, second, millisecond, microsecondOrOpts, opts, isOpts, (y, m, d, h, mi, s, ms, options) => LuxonDateTime.local(y, m, d, h, mi, s, ms, options));
@@ -41,9 +41,6 @@ export interface ToSQLOptions {
41
41
  includeOffset?: boolean;
42
42
  includeOffsetSpace?: boolean;
43
43
  }
44
- export interface DateTimeFormatOptions {
45
- [key: string]: unknown;
46
- }
47
44
  export type DateTimeUnit = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
48
45
  /**
49
46
  * Weekday name type (lowercase).
@@ -50,10 +50,6 @@ export interface ToSQLOptions {
50
50
  includeOffsetSpace?: boolean
51
51
  }
52
52
 
53
- export interface DateTimeFormatOptions {
54
- [key: string]: unknown
55
- }
56
-
57
53
  export type DateTimeUnit =
58
54
  | 'year'
59
55
  | 'quarter'
@@ -1,6 +1,6 @@
1
1
  import { Zone } from 'luxon';
2
2
  import { CalendarDateDurationLike, CalendarDateDurationUnit, CalendarDateUnit } from '../../types/calendardate.js';
3
- import { type DateTimeFormatOptions, type DateTimeJSOptions, type DateTimeObject, type LocaleOptions, type WeekdayName } from '../../types/datetime.js';
3
+ import { type DateTimeJSOptions, type DateTimeObject, type LocaleOptions, type WeekdayName } from '../../types/datetime.js';
4
4
  import { DateTime } from './DateTime.js';
5
5
  /**
6
6
  * CalendarDate represents a date without time or timezone information.
@@ -177,7 +177,7 @@ export default class CalendarDate {
177
177
  * CalendarDate.today().toLocaleString({ month: 'long', day: 'numeric', year: 'numeric' })
178
178
  * ```
179
179
  */
180
- toLocaleString(formatOpts?: DateTimeFormatOptions, opts?: LocaleOptions): string;
180
+ toLocaleString(formatOpts?: Intl.DateTimeFormatOptions, opts?: LocaleOptions): string;
181
181
  /**
182
182
  * Returns the date as an ISO string (same as toISO).
183
183
  * @returns ISO date string (e.g., '2026-02-07')
@@ -1,6 +1,6 @@
1
1
  import * as luxon from 'luxon';
2
2
  import { DateTime as LuxonDateTime } from 'luxon';
3
- import { DateTimeFormatOptions, DateTimeJSOptions, DateTimeObject, DateTimeOptions, DateTimeUnit, DiffResult, DurationLikeObject, DurationUnit, LocaleOptions, ToISOTimeOptions, ToSQLOptions, WeekdayName, Zone } from '../../types/datetime.js';
3
+ import { DateTimeJSOptions, DateTimeObject, DateTimeOptions, DateTimeUnit, DiffResult, DurationLikeObject, DurationUnit, LocaleOptions, ToISOTimeOptions, ToSQLOptions, WeekdayName, Zone } from '../../types/datetime.js';
4
4
  export declare const Settings: typeof luxon.Settings;
5
5
  /**
6
6
  * DateTime wraps Luxon DateTime with microsecond precision (0-999).
@@ -68,6 +68,182 @@ export declare class DateTime {
68
68
  * ```
69
69
  */
70
70
  static now(): DateTime;
71
+ /**
72
+ * {@link DateTime.toLocaleString} format like 10/14/1983
73
+ * @example
74
+ * ```ts
75
+ * DateTime.now().toLocaleString(DateTime.DATE_SHORT)
76
+ * ```
77
+ */
78
+ static get DATE_SHORT(): Intl.DateTimeFormatOptions;
79
+ /**
80
+ * {@link DateTime.toLocaleString} format like 'Oct 14, 1983'
81
+ * @example
82
+ * ```ts
83
+ * DateTime.now().toLocaleString(DateTime.DATE_MED)
84
+ * ```
85
+ */
86
+ static get DATE_MED(): Intl.DateTimeFormatOptions;
87
+ /**
88
+ * {@link DateTime.toLocaleString} format like 'Fri, Oct 14, 1983'
89
+ * @example
90
+ * ```ts
91
+ * DateTime.now().toLocaleString(DateTime.DATE_MED_WITH_WEEKDAY)
92
+ * ```
93
+ */
94
+ static get DATE_MED_WITH_WEEKDAY(): Intl.DateTimeFormatOptions;
95
+ /**
96
+ * {@link DateTime.toLocaleString} format like 'October 14, 1983'
97
+ * @example
98
+ * ```ts
99
+ * DateTime.now().toLocaleString(DateTime.DATE_FULL)
100
+ * ```
101
+ */
102
+ static get DATE_FULL(): Intl.DateTimeFormatOptions;
103
+ /**
104
+ * {@link DateTime.toLocaleString} format like 'Tuesday, October 14, 1983'
105
+ * @example
106
+ * ```ts
107
+ * DateTime.now().toLocaleString(DateTime.DATE_HUGE)
108
+ * ```
109
+ */
110
+ static get DATE_HUGE(): Intl.DateTimeFormatOptions;
111
+ /**
112
+ * {@link DateTime.toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is.
113
+ * @example
114
+ * ```ts
115
+ * DateTime.now().toLocaleString(DateTime.TIME_SIMPLE)
116
+ * ```
117
+ */
118
+ static get TIME_SIMPLE(): Intl.DateTimeFormatOptions;
119
+ /**
120
+ * {@link DateTime.toLocaleString} format like '09:30:23 AM'. Only 12-hour if the locale is.
121
+ * @example
122
+ * ```ts
123
+ * DateTime.now().toLocaleString(DateTime.TIME_WITH_SECONDS)
124
+ * ```
125
+ */
126
+ static get TIME_WITH_SECONDS(): Intl.DateTimeFormatOptions;
127
+ /**
128
+ * {@link DateTime.toLocaleString} format like '09:30:23 AM EDT'. Only 12-hour if the locale is.
129
+ * @example
130
+ * ```ts
131
+ * DateTime.now().toLocaleString(DateTime.TIME_WITH_SHORT_OFFSET)
132
+ * ```
133
+ */
134
+ static get TIME_WITH_SHORT_OFFSET(): Intl.DateTimeFormatOptions;
135
+ /**
136
+ * {@link DateTime.toLocaleString} format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is.
137
+ * @example
138
+ * ```ts
139
+ * DateTime.now().toLocaleString(DateTime.TIME_WITH_LONG_OFFSET)
140
+ * ```
141
+ */
142
+ static get TIME_WITH_LONG_OFFSET(): Intl.DateTimeFormatOptions;
143
+ /**
144
+ * {@link DateTime.toLocaleString} format like '09:30', always 24-hour.
145
+ * @example
146
+ * ```ts
147
+ * DateTime.now().toLocaleString(DateTime.TIME_24_SIMPLE)
148
+ * ```
149
+ */
150
+ static get TIME_24_SIMPLE(): Intl.DateTimeFormatOptions;
151
+ /**
152
+ * {@link DateTime.toLocaleString} format like '09:30:23', always 24-hour.
153
+ * @example
154
+ * ```ts
155
+ * DateTime.now().toLocaleString(DateTime.TIME_24_WITH_SECONDS)
156
+ * ```
157
+ */
158
+ static get TIME_24_WITH_SECONDS(): Intl.DateTimeFormatOptions;
159
+ /**
160
+ * {@link DateTime.toLocaleString} format like '09:30:23 EDT', always 24-hour.
161
+ * @example
162
+ * ```ts
163
+ * DateTime.now().toLocaleString(DateTime.TIME_24_WITH_SHORT_OFFSET)
164
+ * ```
165
+ */
166
+ static get TIME_24_WITH_SHORT_OFFSET(): Intl.DateTimeFormatOptions;
167
+ /**
168
+ * {@link DateTime.toLocaleString} format like '09:30:23 Eastern Daylight Time', always 24-hour.
169
+ * @example
170
+ * ```ts
171
+ * DateTime.now().toLocaleString(DateTime.TIME_24_WITH_LONG_OFFSET)
172
+ * ```
173
+ */
174
+ static get TIME_24_WITH_LONG_OFFSET(): Intl.DateTimeFormatOptions;
175
+ /**
176
+ * {@link DateTime.toLocaleString} format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.
177
+ * @example
178
+ * ```ts
179
+ * DateTime.now().toLocaleString(DateTime.DATETIME_SHORT)
180
+ * ```
181
+ */
182
+ static get DATETIME_SHORT(): Intl.DateTimeFormatOptions;
183
+ /**
184
+ * {@link DateTime.toLocaleString} format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.
185
+ * @example
186
+ * ```ts
187
+ * DateTime.now().toLocaleString(DateTime.DATETIME_SHORT_WITH_SECONDS)
188
+ * ```
189
+ */
190
+ static get DATETIME_SHORT_WITH_SECONDS(): Intl.DateTimeFormatOptions;
191
+ /**
192
+ * {@link DateTime.toLocaleString} format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is.
193
+ * @example
194
+ * ```ts
195
+ * DateTime.now().toLocaleString(DateTime.DATETIME_MED)
196
+ * ```
197
+ */
198
+ static get DATETIME_MED(): Intl.DateTimeFormatOptions;
199
+ /**
200
+ * {@link DateTime.toLocaleString} format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is.
201
+ * @example
202
+ * ```ts
203
+ * DateTime.now().toLocaleString(DateTime.DATETIME_MED_WITH_SECONDS)
204
+ * ```
205
+ */
206
+ static get DATETIME_MED_WITH_SECONDS(): Intl.DateTimeFormatOptions;
207
+ /**
208
+ * {@link DateTime.toLocaleString} format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is.
209
+ * @example
210
+ * ```ts
211
+ * DateTime.now().toLocaleString(DateTime.DATETIME_MED_WITH_WEEKDAY)
212
+ * ```
213
+ */
214
+ static get DATETIME_MED_WITH_WEEKDAY(): Intl.DateTimeFormatOptions;
215
+ /**
216
+ * {@link DateTime.toLocaleString} format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is.
217
+ * @example
218
+ * ```ts
219
+ * DateTime.now().toLocaleString(DateTime.DATETIME_FULL)
220
+ * ```
221
+ */
222
+ static get DATETIME_FULL(): Intl.DateTimeFormatOptions;
223
+ /**
224
+ * {@link DateTime.toLocaleString} format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is.
225
+ * @example
226
+ * ```ts
227
+ * DateTime.now().toLocaleString(DateTime.DATETIME_FULL_WITH_SECONDS)
228
+ * ```
229
+ */
230
+ static get DATETIME_FULL_WITH_SECONDS(): Intl.DateTimeFormatOptions;
231
+ /**
232
+ * {@link DateTime.toLocaleString} format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is.
233
+ * @example
234
+ * ```ts
235
+ * DateTime.now().toLocaleString(DateTime.DATETIME_HUGE)
236
+ * ```
237
+ */
238
+ static get DATETIME_HUGE(): Intl.DateTimeFormatOptions;
239
+ /**
240
+ * {@link DateTime.toLocaleString} format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is.
241
+ * @example
242
+ * ```ts
243
+ * DateTime.now().toLocaleString(DateTime.DATETIME_HUGE_WITH_SECONDS)
244
+ * ```
245
+ */
246
+ static get DATETIME_HUGE_WITH_SECONDS(): Intl.DateTimeFormatOptions;
71
247
  /**
72
248
  * Create a local DateTime. Accepts the same overloads as Luxon plus an optional microsecond (8th numeric arg).
73
249
  * The last argument may be an options object instead of a time component.
@@ -317,7 +493,7 @@ export declare class DateTime {
317
493
  * DateTime.local(2017, 3, 12).toLocaleString()
318
494
  * ```
319
495
  */
320
- toLocaleString(formatOpts?: DateTimeFormatOptions, opts?: LocaleOptions): string;
496
+ toLocaleString(formatOpts?: Intl.DateTimeFormatOptions, opts?: LocaleOptions): string;
321
497
  /**
322
498
  * Returns a string representation using a format string.
323
499
  * Supports all Luxon format tokens. Fractional second tokens (S, SSS, SSSSSS) are enhanced