@@ -7,7 +7,6 @@ var totalTime, averageTime;
77var tabsFromStorage ;
88var targetTabs ;
99var currentTypeOfList ;
10- var today = new Date ( ) . toLocaleDateString ( "en-US" ) ;
1110var setting_range_days ;
1211var setting_dark_mode ;
1312var restrictionList ;
@@ -202,11 +201,11 @@ function getTabsFromStorage(tabs) {
202201 counterOfSite = tabs . length ;
203202 }
204203 if ( currentTypeOfList === TypeListEnum . ToDay ) {
205- targetTabs = tabs . filter ( x => x . days . find ( s => s . date === today ) ) ;
204+ targetTabs = tabs . filter ( x => x . days . find ( s => s . date === todayLocalDate ( ) ) ) ;
206205 counterOfSite = targetTabs . length ;
207206 if ( targetTabs . length > 0 ) {
208207 targetTabs = targetTabs . sort ( function ( a , b ) {
209- return b . days . find ( s => s . date === today ) . summary - a . days . find ( s => s . date === today ) . summary ;
208+ return b . days . find ( s => s . date === todayLocalDate ( ) ) . summary - a . days . find ( s => s . date === todayLocalDate ( ) ) . summary ;
210209 } ) ;
211210
212211 totalTime = getTotalTime ( targetTabs ) ;
@@ -230,9 +229,10 @@ function getTabsFromStorage(tabs) {
230229 var summaryTime ;
231230 var counter ;
232231 if ( currentTypeOfList === TypeListEnum . ToDay ) {
233- summaryTime = targetTabs [ i ] . days . find ( x => x . date == today ) . summary ;
234- if ( targetTabs [ i ] . days . find ( x => x . date == today ) )
235- counter = targetTabs [ i ] . days . find ( x => x . date == today ) . counter ;
232+ summaryTime = targetTabs [ i ] . days . find ( x => x . date == todayLocalDate ( ) ) . summary ;
233+ let item = targetTabs [ i ] . days . find ( x => x . date == todayLocalDate ( ) ) ;
234+ if ( item != null )
235+ counter = item . counter ;
236236 }
237237 if ( currentTypeOfList === TypeListEnum . All ) {
238238 summaryTime = targetTabs [ i ] . summaryTime ;
@@ -263,7 +263,7 @@ function getTabsForTimeChart(timeIntervals) {
263263 var resultArr = [ ] ;
264264 if ( timeIntervals != undefined ) {
265265 timeIntervals . forEach ( function ( data ) {
266- if ( data . day == today ) {
266+ if ( data . day == todayLocalDate ( ) ) {
267267 data . intervals . forEach ( function ( interval ) {
268268 resultArr . push ( { 'domain' : data . domain , 'interval' : interval } ) ;
269269 } ) ;
@@ -300,9 +300,10 @@ function getTabsFromStorageForExpander(tabs) {
300300 var summaryTime ;
301301 var counter ;
302302 if ( currentTypeOfList === TypeListEnum . ToDay ) {
303- summaryTime = targetTabs [ i ] . days . find ( x => x . date == today ) . summary ;
304- if ( targetTabs [ i ] . days . find ( x => x . date == today ) )
305- counter = targetTabs [ i ] . days . find ( x => x . date == today ) . counter ;
303+ summaryTime = targetTabs [ i ] . days . find ( x => x . date == todayLocalDate ( ) ) . summary ;
304+ let item = targetTabs [ i ] . days . find ( x => x . date == todayLocalDate ( ) ) ;
305+ if ( item != undefined )
306+ counter = item . counter ;
306307 }
307308 if ( currentTypeOfList === TypeListEnum . All ) {
308309 summaryTime = targetTabs [ i ] . summaryTime ;
@@ -320,7 +321,7 @@ function getTabsFromStorageForExpander(tabs) {
320321function getTotalTime ( tabs ) {
321322 var total ;
322323 if ( currentTypeOfList === TypeListEnum . ToDay ) {
323- var summaryTimeList = tabs . map ( function ( a ) { return a . days . find ( s => s . date === today ) . summary ; } ) ;
324+ var summaryTimeList = tabs . map ( function ( a ) { return a . days . find ( s => s . date === todayLocalDate ( ) ) . summary ; } ) ;
324325 total = summaryTimeList . reduce ( function ( a , b ) { return a + b ; } )
325326 }
326327 if ( currentTypeOfList === TypeListEnum . All ) {
@@ -410,7 +411,7 @@ function setStatData(array) {
410411 } ) ;
411412
412413 arrayAscByTimeWithoutCurrentDay = arrayAscByTime . filter ( function ( item ) {
413- return item . date != today ;
414+ return item . date != todayLocalDate ( ) ;
414415 } )
415416
416417 arrayAscByTime = arrayAscByTime . sort ( function ( a , b ) {
@@ -421,15 +422,15 @@ function setStatData(array) {
421422 return a . total - b . total ;
422423 } ) ;
423424
424- stat . inActiveDay = new Date ( arrayAscByTime [ 0 ] . date ) . toLocaleDateString ( 'ru-RU' ) ;
425- stat . activeDay = new Date ( arrayAscByTime [ arrayAscByTime . length - 1 ] . date ) . toLocaleDateString ( 'ru-RU' ) ; ;
425+ stat . inActiveDay = new Date ( arrayAscByTime [ 0 ] . date ) . toLocaleDateString ( ) ;
426+ stat . activeDay = new Date ( arrayAscByTime [ arrayAscByTime . length - 1 ] . date ) . toLocaleDateString ( ) ; ;
426427 stat . inActiveDayTime = arrayAscByTime [ 0 ] . total ;
427428 stat . activeDayTime = arrayAscByTime [ arrayAscByTime . length - 1 ] . total ;
428429
429430 //exclude current day from summary statistics
430431 if ( arrayAscByTimeWithoutCurrentDay . length > 0 ) {
431- stat . inActiveDayWithoutCurrentDay = new Date ( arrayAscByTimeWithoutCurrentDay [ 0 ] . date ) . toLocaleDateString ( 'ru-RU' ) ;
432- stat . activeDayWithoutCurrentDay = new Date ( arrayAscByTimeWithoutCurrentDay [ arrayAscByTimeWithoutCurrentDay . length - 1 ] . date ) . toLocaleDateString ( 'ru-RU' ) ;
432+ stat . inActiveDayWithoutCurrentDay = new Date ( arrayAscByTimeWithoutCurrentDay [ 0 ] . date ) . toLocaleDateString ( ) ;
433+ stat . activeDayWithoutCurrentDay = new Date ( arrayAscByTimeWithoutCurrentDay [ arrayAscByTimeWithoutCurrentDay . length - 1 ] . date ) . toLocaleDateString ( ) ;
433434 stat . inActiveDayTimeWithoutCurrentDay = arrayAscByTimeWithoutCurrentDay [ 0 ] . total ;
434435 stat . activeDayTimeWithoutCurrentDay = arrayAscByTimeWithoutCurrentDay [ arrayAscByTimeWithoutCurrentDay . length - 1 ] . total ;
435436 }
@@ -438,7 +439,7 @@ function setStatData(array) {
438439 stat . inActiveDayWithoutCurrentDay = 'No data' ;
439440 }
440441
441- stat . firstDay = new Date ( array [ 0 ] ) . toLocaleDateString ( 'ru-RU' ) ; ;
442+ stat . firstDay = new Date ( array [ 0 ] ) . toLocaleDateString ( ) ; ;
442443 stat . activeDays = array . length ;
443444 stat . averageTime = Math . round ( totalTime / array . length ) ;
444445 stat . totalDays = daysBetween ( array [ 0 ] , array [ array . length - 1 ] ) ;
0 commit comments