@@ -728,6 +728,8 @@ describe('temporal-types', () => {
728
728
testStandardDateToNeo4jDateConversion ( new Date ( 1351 , 4 , 7 ) ) ;
729
729
testStandardDateToNeo4jDateConversion ( new Date ( 3841 , 1 , 19 ) ) ;
730
730
testStandardDateToNeo4jDateConversion ( new Date ( 2222 , 3 , 29 ) ) ;
731
+
732
+ testStandardDateToNeo4jDateConversion ( new Date ( 1567 , 0 , 29 ) ) ;
731
733
} ) ;
732
734
733
735
it ( 'should fail to convert invalid standard Date to neo4j Date' , ( ) => {
@@ -753,6 +755,9 @@ describe('temporal-types', () => {
753
755
testStandardDateToLocalDateTimeConversion ( new Date ( 1922 , 1 , 22 , 23 , 23 , 45 , 123 ) , 456789 ) ;
754
756
755
757
testStandardDateToLocalDateTimeConversion ( new Date ( 1999 , 1 , 1 , 10 , 10 , 10 ) , neo4j . int ( 999 ) ) ;
758
+
759
+ testStandardDateToLocalDateTimeConversion ( new Date ( 2192 , 0 , 17 , 20 , 30 , 40 ) ) ;
760
+ testStandardDateToLocalDateTimeConversion ( new Date ( 2239 , 0 , 9 , 1 , 2 , 3 ) , 4 ) ;
756
761
} ) ;
757
762
758
763
it ( 'should fail to convert invalid standard Date to neo4j LocalDateTime' , ( ) => {
@@ -782,6 +787,9 @@ describe('temporal-types', () => {
782
787
783
788
testStandardDateToDateTimeConversion ( new Date ( 1922 , 1 , 22 , 23 , 23 , 45 , 123 ) , 456789 ) ;
784
789
testStandardDateToDateTimeConversion ( new Date ( 1999 , 1 , 1 , 10 , 10 , 10 ) , neo4j . int ( 999 ) ) ;
790
+
791
+ testStandardDateToDateTimeConversion ( new Date ( 1899 , 0 , 7 , 7 , 7 , 7 , 7 ) ) ;
792
+ testStandardDateToDateTimeConversion ( new Date ( 2005 , 0 , 1 , 2 , 3 , 4 , 5 ) , 100 ) ;
785
793
} ) ;
786
794
787
795
it ( 'should fail to convert invalid standard Date to neo4j DateTime' , ( ) => {
@@ -800,6 +808,45 @@ describe('temporal-types', () => {
800
808
expect ( ( ) => DateTime . fromStandardDate ( new Date ( ) , [ 1 ] ) ) . toThrowError ( TypeError ) ;
801
809
} ) ;
802
810
811
+ it ( 'should send and receive neo4j Date created from standard Date with zero month' , done => {
812
+ if ( neo4jDoesNotSupportTemporalTypes ( done ) ) {
813
+ return ;
814
+ }
815
+
816
+ // return numbers and not integers to simplify the equality comparison
817
+ session = driverWithNativeNumbers . session ( ) ;
818
+
819
+ const standardDate = new Date ( 2000 , 0 , 1 ) ;
820
+ const neo4jDate = neo4j . types . Date . fromStandardDate ( standardDate ) ;
821
+ testSendReceiveTemporalValue ( neo4jDate , done ) ;
822
+ } ) ;
823
+
824
+ it ( 'should send and receive neo4j LocalDateTime created from standard Date with zero month' , done => {
825
+ if ( neo4jDoesNotSupportTemporalTypes ( done ) ) {
826
+ return ;
827
+ }
828
+
829
+ // return numbers and not integers to simplify the equality comparison
830
+ session = driverWithNativeNumbers . session ( ) ;
831
+
832
+ const standardDate = new Date ( 2121 , 0 , 7 , 10 , 20 , 30 , 40 ) ;
833
+ const neo4jLocalDateTime = neo4j . types . LocalDateTime . fromStandardDate ( standardDate ) ;
834
+ testSendReceiveTemporalValue ( neo4jLocalDateTime , done ) ;
835
+ } ) ;
836
+
837
+ it ( 'should send and receive neo4j DateTime created from standard Date with zero month' , done => {
838
+ if ( neo4jDoesNotSupportTemporalTypes ( done ) ) {
839
+ return ;
840
+ }
841
+
842
+ // return numbers and not integers to simplify the equality comparison
843
+ session = driverWithNativeNumbers . session ( ) ;
844
+
845
+ const standardDate = new Date ( 1756 , 0 , 29 , 23 , 15 , 59 , 12 ) ;
846
+ const neo4jDateTime = neo4j . types . DateTime . fromStandardDate ( standardDate ) ;
847
+ testSendReceiveTemporalValue ( neo4jDateTime , done ) ;
848
+ } ) ;
849
+
803
850
function testSendAndReceiveRandomTemporalValues ( valueGenerator , done ) {
804
851
const asyncFunction = ( index , callback ) => {
805
852
const next = ( ) => callback ( ) ;
@@ -1002,20 +1049,20 @@ describe('temporal-types', () => {
1002
1049
1003
1050
function testStandardDateToNeo4jDateConversion ( date ) {
1004
1051
const converted = neo4j . types . Date . fromStandardDate ( date ) ;
1005
- const expected = new neo4j . types . Date ( date . getFullYear ( ) , date . getMonth ( ) , date . getDate ( ) ) ;
1052
+ const expected = new neo4j . types . Date ( date . getFullYear ( ) , date . getMonth ( ) + 1 , date . getDate ( ) ) ;
1006
1053
expect ( converted ) . toEqual ( expected ) ;
1007
1054
}
1008
1055
1009
1056
function testStandardDateToLocalDateTimeConversion ( date , nanosecond ) {
1010
1057
const converted = neo4j . types . LocalDateTime . fromStandardDate ( date , nanosecond ) ;
1011
- const expected = new neo4j . types . LocalDateTime ( date . getFullYear ( ) , date . getMonth ( ) , date . getDate ( ) , date . getHours ( ) , date . getMinutes ( ) , date . getSeconds ( ) ,
1012
- totalNanoseconds ( date , nanosecond ) ) ;
1058
+ const expected = new neo4j . types . LocalDateTime ( date . getFullYear ( ) , date . getMonth ( ) + 1 , date . getDate ( ) , date . getHours ( ) , date . getMinutes ( ) ,
1059
+ date . getSeconds ( ) , totalNanoseconds ( date , nanosecond ) ) ;
1013
1060
expect ( converted ) . toEqual ( expected ) ;
1014
1061
}
1015
1062
1016
1063
function testStandardDateToDateTimeConversion ( date , nanosecond ) {
1017
1064
const converted = neo4j . types . DateTime . fromStandardDate ( date , nanosecond ) ;
1018
- const expected = new neo4j . types . DateTime ( date . getFullYear ( ) , date . getMonth ( ) , date . getDate ( ) , date . getHours ( ) , date . getMinutes ( ) , date . getSeconds ( ) ,
1065
+ const expected = new neo4j . types . DateTime ( date . getFullYear ( ) , date . getMonth ( ) + 1 , date . getDate ( ) , date . getHours ( ) , date . getMinutes ( ) , date . getSeconds ( ) ,
1019
1066
totalNanoseconds ( date , nanosecond ) , date . getTimezoneOffset ( ) * 60 ) ;
1020
1067
expect ( converted ) . toEqual ( expected ) ;
1021
1068
}
0 commit comments