<commit_before>var schedule = require('node-schedule');
var eibd = require('eibd');
var moment = require('moment');
var timeJob, dateJob;

var createTimeJob = function (opts, addresses, cronStr, dptType, value, callback) {
    schedule.scheduleJob(cronStr, function() {
        var conn = eibd.Connection();
        conn.socketRemote(opts, function() {
            conn.openTGroup(address, 1, function (err) {
                if(err) {
                    callback(err);
                } else {
                    var msg = eibd.createMessage('write', 'DPT10', parseInt(value));
                    conn.sendAPDU(msg, callback);
                }
            });
        });
    });
};

var startTime = function (opts, addresses, cronStr, callback) {
    if (timeJob) {
        timeJob.cancel();
    }
    // For the time the value must be: [dayOfTheWeek, hour, minutes, seconds]
    var time = [];
    var mom =  moment();
    time[0] = mom.isoWeekday();
    time[1] = mom.hour();
    time[2] = mom.minute();
    time[3] = mom.seconds();
    timeJob = createTimeJob(opts, addresses, cronStr, 'DPT10',callback);
};

var startDate = function (opts, addresses, cronStr, callback) {
    if (dateJob) {
        dateJob.cancel();
    }
    // For the date the value must be:  [day, month, year]
    var time = [];
    var mom =  moment();
    time[0] = mom.month() + 1; // for moment, january it's 0.
    time[1] = mom.year();
    timeJob = createTimeJob(opts, addresses, cronStr, 'DPT11',callback);
};

module.exports = {
    startTime: startTime,
    startDate: startDate
};


/**
 * groupwrite
 * send a group write telegram to a group address (for DPT5 values)
 */
function groupwrite(opts, gad, value, callback) {

  var conn = eibd.Connection();

  var address = eibd.str2addr(gad);

  conn.socketRemote(opts, function() {
    conn.openTGroup(address, 1, function (err) {

      if(err) {
        callback(err);
      } else {
      var msg = eibd.createMessage('write', 'DPT5', parseInt(value));
      conn.sendAPDU(msg, callback);
      }

    });
  });
}<commit_msg>Fixed<commit_after>var schedule = require('node-schedule');
var eibd = require('eibd');
var moment = require('moment');
var timeJob, dateJob;

var createTimeJob = function (opts, addresses, cronStr, dptType, value, callback) {
    schedule.scheduleJob(cronStr, function() {
        var conn = eibd.Connection();
        conn.socketRemote(opts, function() {
            conn.openTGroup(address, 1, function (err) {
                if(err) {
                    callback(err);
                } else {
                    var msg = eibd.createMessage('write', 'DPT10', parseInt(value));
                    conn.sendAPDU(msg, callback);
                }
            });
        });
    });
};

var startTime = function (opts, addresses, cronStr, callback) {
    if (timeJob) {
        timeJob.cancel();
    }
    // For the time the value must be: [dayOfTheWeek, hour, minutes, seconds]
    var time = [];
    var mom =  moment();
    time[0] = mom.isoWeekday();
    time[1] = mom.hour();
    time[2] = mom.minute();
    time[3] = mom.seconds();
    timeJob = createTimeJob(opts, addresses, cronStr, 'DPT10',callback);
};

var startDate = function (opts, addresses, cronStr, callback) {
    if (dateJob) {
        dateJob.cancel();
    }
    // For the date the value must be:  [day, month, year]
    var time = [];
    var mom =  moment();
    time[0] = mom.month() + 1; // for moment, january it's 0.
    time[1] = mom.year();
    timeJob = createTimeJob(opts, addresses, cronStr, 'DPT11',callback);
};

module.exports = {
    startTime: startTime,
    startDate: startDate
};
{'fraction_non_alphanumeric': 0.14908194025760482, 'fraction_numerical': 0.009317621266100301, 'mean_word_length': 2.4499054820415878, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '150702', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1140, 'n_words': 292}