javascript - Looping through the time-series data in an array and IIFE -
i have time series data in array follows:
// few data given sample out <br> var time - series = [ "2016-11-09 00:30:01.000000", "2016-11-09 00:30:02.000000", "2016-11-09 00:30:03.000000", "2016-11-09 00:30:04.000000", "2016-11-09 00:31:05.000000", "2016-11-09 00:31:06.000000", "2016-11-09 00:31:07.000000", "2016-11-09 00:31:08.000000", "2016-11-09 00:32:09.000000" ]
if notice data, seconds increasing 1 second , when length of array becomes multiple of 4 (modulus of 4), time jumps 1 minute. have generated time-series data 2016-11-09 00:30:01.000000 2016-11-10 00:00:00.000000 using script.
now, feed time-series data script, script loops through array of time-series , print respective time-stamp of time-series[i]
only when respective minute , second part of time-stamp matches system's minute , second part. but, items of time-series[i] getting matched hour , minute of system's time getting printed. script have developed loop through time-stamp given below.
var schedule = require('node-schedule'); var date = ["2016-11-09 00:30:01.000000","2016-11-09 00:30:02.000000","2016-11-09 00:30:03.000000","2016-11-09 00:30:04.000000","2016-11-09 00:31:05.000000","2016-11-09 00:31:06.000000","2016-11-09 00:31:07.000000","2016-11-09 00:31:08.000000","2016-11-09 00:32:09.000000" ......]; (var in date){ (function(i){ var new_date = moment(date[i], "yyyy-mm-dd hh:mm:ss.ssssss"); templatehour = parseint(new_date.format('hh')); templateminute = parseint(new_date.format('mm')); templateseconds = parseint(new_date.format('ss')); schedule.schedulejob({minute: templateminute, second: templateseconds}, function(){ console.log(date[i]); }); })(i); };
Comments
Post a Comment