@@ -12,6 +12,14 @@ import {
1212 DateTime as LuxonDateTime ,
1313 FixedOffsetZone
1414} from 'luxon' ;
15+ import {
16+ MAX_DATE_VALUE_STRING ,
17+ MAX_DATETIME_VALUE_STRING ,
18+ MAX_TIME_VALUE_STRING ,
19+ MIN_DATE_VALUE_STRING ,
20+ MIN_DATETIME_VALUE_STRING ,
21+ MIN_TIME_VALUE_STRING
22+ } from '../util/limits' ;
1523
1624// It's easiest and most performant to organize formats by length of the supported strings.
1725// This way we can test strings only against the formats that have a chance of working.
@@ -550,7 +558,7 @@ abstract class AbstractDate {
550558 case 'millisecond' :
551559 return 999 ;
552560 default :
553- throw new Error ( 'Tried to clieling a field that has no cieling value: ' + field ) ;
561+ throw new Error ( 'Tried to ceiling a field that has no cieling value: ' + field ) ;
554562 }
555563 }
556564}
@@ -722,8 +730,10 @@ export class DateTime extends AbstractDate {
722730 ) ;
723731 }
724732
725- successor ( ) {
726- if ( this . millisecond != null ) {
733+ successor ( precision ?: string ) {
734+ if ( precision ) {
735+ return this . add ( 1 , precision ) ;
736+ } else if ( this . millisecond != null ) {
727737 return this . add ( 1 , DateTime . Unit . MILLISECOND ) ;
728738 } else if ( this . second != null ) {
729739 return this . add ( 1 , DateTime . Unit . SECOND ) ;
@@ -740,8 +750,10 @@ export class DateTime extends AbstractDate {
740750 }
741751 }
742752
743- predecessor ( ) {
744- if ( this . millisecond != null ) {
753+ predecessor ( precision ?: string ) {
754+ if ( precision ) {
755+ return this . add ( - 1 , precision ) ;
756+ } else if ( this . millisecond != null ) {
745757 return this . add ( - 1 , DateTime . Unit . MILLISECOND ) ;
746758 } else if ( this . second != null ) {
747759 return this . add ( - 1 , DateTime . Unit . SECOND ) ;
@@ -1254,13 +1266,12 @@ export class Date extends AbstractDate {
12541266
12551267// Require MIN/MAX here because math.js requires this file, and when we make this file require
12561268// math.js before it exports DateTime and Date, it errors due to the circular dependency...
1257- // const { MAX_DATETIME_VALUE, MIN_DATETIME_VALUE } = require('../util/math');
1258- export const MIN_DATETIME_VALUE = DateTime . parse ( '0001-01-01T00:00:00.000' ) ;
1259- export const MAX_DATETIME_VALUE = DateTime . parse ( '9999-12-31T23:59:59.999' ) ;
1260- export const MIN_DATE_VALUE = Date . parse ( '0001-01-01' ) ;
1261- export const MAX_DATE_VALUE = Date . parse ( '9999-12-31' ) ;
1262- export const MIN_TIME_VALUE = DateTime . parse ( '0000-01-01T00:00:00.000' ) ?. getTime ( ) ;
1263- export const MAX_TIME_VALUE = DateTime . parse ( '0000-01-01T23:59:59.999' ) ?. getTime ( ) ;
1269+ export const MIN_DATETIME_VALUE = DateTime . parse ( MIN_DATETIME_VALUE_STRING ) ;
1270+ export const MAX_DATETIME_VALUE = DateTime . parse ( MAX_DATETIME_VALUE_STRING ) ;
1271+ export const MIN_DATE_VALUE = Date . parse ( MIN_DATE_VALUE_STRING ) ;
1272+ export const MAX_DATE_VALUE = Date . parse ( MAX_DATE_VALUE_STRING ) ;
1273+ export const MIN_TIME_VALUE = DateTime . parse ( MIN_TIME_VALUE_STRING ) ?. getTime ( ) ;
1274+ export const MAX_TIME_VALUE = DateTime . parse ( MAX_TIME_VALUE_STRING ) ?. getTime ( ) ;
12641275
12651276const DATETIME_PRECISION_VALUE_MAP = ( ( ) => {
12661277 const dtpvMap = new Map ( ) ;
0 commit comments