UNPKG

emarsys-test

Version:

Emarsys test application

35 lines (31 loc) 786 B
var moment = require('moment-business-time'); var wh = ['09:00:00', '17:00:00']; moment.updateLocale('en', { workinghours: { 0: wh, 1: wh, 2: wh, 3: wh, 4: wh, 5: null, 6: null } }); //One function is exported to the world exports.CalculateDueDate = function(submitDate,turnaroundTime) { if(isset(submitDate)) { if(isset(turnaroundTime) && turnaroundTime!=0) { submitDate = moment(submitDate); var dueDate = submitDate.addWorkingTime(turnaroundTime,'hours'); return dueDate.format('LLL'); } else { return submitDate; } } else { throw new Error('Submit date not given.'); } } //Determine if a variable is set and not empty function isset(variable) { return typeof variable !== 'undefined' && variable; }