Monday 12 June 2017

How to match fs file dates with date ranges?

I have a date range from client , so i am trying to see if any file that comes in this range only push that file to filesData , I have implemented below code but its not happening any idea where i am making mistake ?

clientInput

{ searchTxt: '82ffefc5-24b3-4cfd-960b-6c60f241c82c',
  searchEnv: 'st',
  searchStartDate: '2017-06-06T18:00:00.000Z',
  searchEndDate: '2017-06-12T16:53:26.509Z' }

search.js

var Directory = require('./stDir');

Directory.readDirectory(function(files){
                        filesData.logFiles = files;
                        if (filesData.logFiles.fileDate - searchStartDate > 0 && searchEndDate - filesData.logFiles.fileDate > 0) {
                            filesData.logFiles.push(files);
                            filesData.searchEnv = searchObj.searchEnv;
                            asyncFiles(filesData);
                        }

                 });

files Date Data

[{ fileDate: Mon Jun 06 2017 12:08:33 GMT-0400 (Eastern Daylight Time),
       filename: 'server20170612120833.log' },
     { fileDate: Mon Jun 12 2017 12:42:55 GMT-0400 (Eastern Daylight Time),
       filename: 'server20170612124255.log' } ]



via hussain

No comments:

Post a Comment