@@ -115,16 +115,36 @@ describe('SearchManager', (sqlHelper: DBTestHelper) => {
115115 subDir2 = TestHelper . getDirectoryEntry ( directory , 'Return of the Jedi' ) ;
116116 p = TestHelper . getPhotoEntry1 ( directory ) ;
117117 p . metadata . creationDate = Date . now ( ) ;
118+ p . metadata . creationDateOffset = "+02:00" ;
118119 p2 = TestHelper . getPhotoEntry2 ( directory ) ;
119120 p2 . metadata . creationDate = Date . now ( ) - 60 * 60 * 24 * 1000 ;
121+ p2 . metadata . creationDateOffset = "+02:00" ;
120122 v = TestHelper . getVideoEntry1 ( directory ) ;
121123 v . metadata . creationDate = Date . now ( ) - 60 * 60 * 24 * 7 * 1000 ;
124+ v . metadata . creationDateOffset = "+02:00" ;
122125 gpx = TestHelper . getRandomizedGPXEntry ( directory ) ;
123126 p4 = TestHelper . getPhotoEntry4 ( subDir2 ) ;
124- p4 . metadata . creationDate = Date . now ( ) - 60 * 60 * 24 * 366 * 1000 ;
127+ let d = new Date ( ) ;
128+ //set creation date to one year and one day earlier
129+ p4 . metadata . creationDate = d . getTime ( ) - 60 * 60 * 24 * ( Utils . isDateFromLeapYear ( d ) ? 367 : 366 ) * 1000 ;
130+ p4 . metadata . creationDateOffset = "+02:00" ;
125131 const pFaceLessTmp = TestHelper . getPhotoEntry3 ( subDir ) ;
126132 delete pFaceLessTmp . metadata . faces ;
127- pFaceLessTmp . metadata . creationDate = Date . now ( ) - 60 * 60 * 24 * 32 * 1000 ;
133+ d = new Date ( ) ;
134+ //we create a date 1 month and 1 day before now
135+ if ( [ 1 , 3 , 5 , 7 , 8 , 10 , 0 ] . includes ( d . getMonth ( ) ) ) {
136+ //Now is a month after a long month: feb (1), april (3), june (5), august(7), september(8), november (10), january (0)
137+ pFaceLessTmp . metadata . creationDate = d . getTime ( ) - 60 * 60 * 24 * 32 * 1000 ;
138+ } else if ( d . getMonth ( ) == 2 && Utils . isDateFromLeapYear ( d ) ) {
139+ //march on leap years
140+ pFaceLessTmp . metadata . creationDate = d . getTime ( ) - 60 * 60 * 24 * 30 * 1000 ;
141+ } else if ( d . getMonth ( ) == 2 ) {
142+ //march (and not leap years)
143+ pFaceLessTmp . metadata . creationDate = d . getTime ( ) - 60 * 60 * 24 * 29 * 1000 ;
144+ } else { //all other months must come after a short month with 30 days, so we subtract 31
145+ pFaceLessTmp . metadata . creationDate = d . getTime ( ) - 60 * 60 * 24 * 31 * 1000 ;
146+ }
147+ pFaceLessTmp . metadata . creationDateOffset = "+02:00" ;
128148
129149 dir = await DBTestHelper . persistTestDir ( directory ) ;
130150 subDir = dir . directories [ 0 ] ;
@@ -937,13 +957,16 @@ describe('SearchManager', (sqlHelper: DBTestHelper) => {
937957 await setUpSqlDB ( ) ;
938958 p5 = TestHelper . getBasePhotoEntry ( subDir2 , 'p5-23h-ago.jpg' ) ;
939959 p5 . metadata . creationDate = Date . now ( ) - 60 * 60 * 24 * 1000 - 1000 ;
960+ //p5.metadata.creationDateOffset = "+02:00";
940961 p6 = TestHelper . getBasePhotoEntry ( subDir2 , 'p6-300d-ago.jpg' ) ;
941962 p6 . metadata . creationDate = Date . now ( ) - 60 * 60 * 24 * 300 * 1000 ;
963+ //p6.metadata.creationDateOffset = "+02:00";
942964 p7 = TestHelper . getBasePhotoEntry ( subDir2 , 'p7-1y-1min-ago.jpg' ) ;
943965 const d = new Date ( ) ;
944966 d . setUTCFullYear ( d . getUTCFullYear ( ) - 1 ) ;
945967 d . setUTCMinutes ( d . getUTCMinutes ( ) - 1 ) ;
946968 p7 . metadata . creationDate = d . getTime ( ) ;
969+ //p7.metadata.creationDateOffset = "+02:00";
947970
948971 subDir2 = await DBTestHelper . persistTestDir ( subDir2 ) as any ;
949972 p4 = subDir2 . media [ 0 ] ;
0 commit comments