@@ -1416,6 +1416,46 @@ describe('DateTimeInterval', () => {
14161416 dateTimeIntervalWithBoundlessLow . sameAs ( dateIntervalWithBoundlessLow ) . should . be . true ( ) ;
14171417 } ) ;
14181418
1419+ it ( 'should convert uncertain Date interval boundaries to DateTime' , ( ) => {
1420+ const dateLow = Date . parse ( '2012-01-01' ) ;
1421+ const dateHigh = Date . parse ( '2012-12-31' ) ;
1422+ const dateTimeLow = DateTime . parse ( '2012-01-01' ) ;
1423+ const dateTimeHigh = DateTime . parse ( '2012-12-31' ) ;
1424+ const dateIntervalWithUncertainLow = new Interval (
1425+ new Uncertainty ( dateLow ) ,
1426+ dateHigh ,
1427+ true ,
1428+ true ,
1429+ ELM_DATE_TYPE
1430+ ) ;
1431+ const dateTimeIntervalWithUncertainLow = new Interval (
1432+ new Uncertainty ( dateTimeLow ) ,
1433+ dateTimeHigh ,
1434+ true ,
1435+ true ,
1436+ ELM_DATETIME_TYPE
1437+ ) ;
1438+ const dateIntervalWithUncertainHigh = new Interval (
1439+ dateLow ,
1440+ new Uncertainty ( dateHigh ) ,
1441+ true ,
1442+ true ,
1443+ ELM_DATE_TYPE
1444+ ) ;
1445+ const dateTimeIntervalWithUncertainHigh = new Interval (
1446+ dateTimeLow ,
1447+ new Uncertainty ( dateTimeHigh ) ,
1448+ true ,
1449+ true ,
1450+ ELM_DATETIME_TYPE
1451+ ) ;
1452+
1453+ dateIntervalWithUncertainLow . sameAs ( dateTimeIntervalWithUncertainLow ) . should . be . true ( ) ;
1454+ dateTimeIntervalWithUncertainLow . sameAs ( dateIntervalWithUncertainLow ) . should . be . true ( ) ;
1455+ dateIntervalWithUncertainHigh . sameAs ( dateTimeIntervalWithUncertainHigh ) . should . be . true ( ) ;
1456+ dateTimeIntervalWithUncertainHigh . sameAs ( dateIntervalWithUncertainHigh ) . should . be . true ( ) ;
1457+ } ) ;
1458+
14191459 it ( 'should properly handle boundless and unknown intervals' , ( ) => {
14201460 boundlessInterval ( ELM_DATETIME_TYPE )
14211461 . sameAs ( boundlessInterval ( ELM_DATETIME_TYPE ) )
@@ -1920,6 +1960,30 @@ describe('DateTimeInterval', () => {
19201960 . should . equalInterval ( new Interval ( x . toMinute . high , y . toDay . high , false , true ) ) ;
19211961 } ) ;
19221962
1963+ it ( 'should handle null temporal boundaries when determining precision' , ( ) => {
1964+ const a = new Interval ( null , DateTime . parse ( '2012-12-31' ) ) ;
1965+ const b = new Interval ( DateTime . parse ( '2012-06-01' ) , DateTime . parse ( '2013-01-01' ) ) ;
1966+ a . except ( b ) . should . equalInterval (
1967+ new Interval ( null , DateTime . parse ( '2012-06-01' ) , true , false )
1968+ ) ;
1969+ } ) ;
1970+
1971+ it ( 'should handle uncertain temporal boundaries when determining precision' , ( ) => {
1972+ const a = new Interval (
1973+ new Uncertainty ( DateTime . parse ( '2012-01-01' ) , DateTime . parse ( '2012-01-31' ) ) ,
1974+ DateTime . parse ( '2012-12-31' )
1975+ ) ;
1976+ const b = new Interval ( DateTime . parse ( '2012-06-01' ) , DateTime . parse ( '2013-01-01' ) ) ;
1977+ a . except ( b ) . should . equalInterval (
1978+ new Interval (
1979+ new Uncertainty ( DateTime . parse ( '2012-01-01' ) , DateTime . parse ( '2012-01-31' ) ) ,
1980+ DateTime . parse ( '2012-06-01' ) ,
1981+ true ,
1982+ false
1983+ )
1984+ ) ;
1985+ } ) ;
1986+
19231987 it ( 'should throw when the argument is a point' , ( ) => {
19241988 should ( ( ) => d . all2012 . closed . except ( DateTime . parse ( '2012-07-01T00:00:00.0' ) ) ) . throw ( Error ) ;
19251989 } ) ;
0 commit comments