Allow international formatted dates in CSV imports
This commit is contained in:
parent
1513c761bc
commit
9778c486e9
5 changed files with 27 additions and 15 deletions
|
@ -514,18 +514,27 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
|
|||
} else {
|
||||
value = (value || '').toString().trim();
|
||||
|
||||
let parts = value.match(/(\d+)\D+(\d+)(?:\D+(\d+))?/);
|
||||
if (!parts) {
|
||||
value = null;
|
||||
// try international format first YYYY-MM-DD
|
||||
let parts = value.match(/(\d{4})\D+(\d{2})(?:\D+(\d{2})\b)?/);
|
||||
if (parts) {
|
||||
year = Number(parts[1]) || 2000;
|
||||
month = Number(parts[2]) || 0;
|
||||
day = Number(parts[3]) || 0;
|
||||
value = new Date(Date.UTC(year, month - 1, day));
|
||||
} else {
|
||||
day = Number(parts[isUs ? 2 : 1]) || 0;
|
||||
month = Number(parts[isUs ? 1 : 2]) || 0;
|
||||
year = Number(parts[3]) || 2000;
|
||||
|
||||
if (!day || !month) {
|
||||
parts = value.match(/(\d+)\D+(\d+)(?:\D+(\d+)\b)?/);
|
||||
if (!parts) {
|
||||
value = null;
|
||||
} else {
|
||||
value = new Date(Date.UTC(year, month - 1, day));
|
||||
day = Number(parts[isUs ? 2 : 1]) || 0;
|
||||
month = Number(parts[isUs ? 1 : 2]) || 0;
|
||||
year = Number(parts[3]) || 2000;
|
||||
|
||||
if (!day || !month) {
|
||||
value = null;
|
||||
} else {
|
||||
value = new Date(Date.UTC(year, month - 1, day));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,12 @@ let tools = require('../lib/tools');
|
|||
let feed = require('../lib/feed');
|
||||
let campaigns = require('../lib/models/campaigns');
|
||||
|
||||
const feed_timeout = 15 * 1000;
|
||||
const rss_timeout = 1 * 1000;
|
||||
|
||||
function feedLoop() {
|
||||
|
||||
db.getConnection((err, connection) => {
|
||||
const feed_timeout = 15 * 1000;
|
||||
if (err) {
|
||||
log.error('Feed', err.stack);
|
||||
return setTimeout(feedLoop, feed_timeout);
|
||||
|
@ -32,7 +34,6 @@ function feedLoop() {
|
|||
let parent = tools.convertKeys(rows[0]);
|
||||
|
||||
updateRssInfo(parent.id, true, false, () => {
|
||||
const rss_timeout = 1 * 1000;
|
||||
log.verbose('Feed', 'Checking feed %s (%s)', parent.sourceUrl, parent.id);
|
||||
feed.fetch(parent.sourceUrl, (err, entries) => {
|
||||
if (err) {
|
||||
|
|
|
@ -10,6 +10,8 @@ let subscriptions = require('../lib/models/subscriptions');
|
|||
let fs = require('fs');
|
||||
let csvparse = require('csv-parse');
|
||||
|
||||
const process_timout = 5 * 1000;
|
||||
|
||||
function findUnprocessed(callback) {
|
||||
db.getConnection((err, connection) => {
|
||||
if (err) {
|
||||
|
@ -221,7 +223,6 @@ function processImport(data, callback) {
|
|||
|
||||
let importLoop = () => {
|
||||
let getNext = () => {
|
||||
const process_timout = 5 * 1000;
|
||||
// find an unsent message
|
||||
findUnprocessed((err, data) => {
|
||||
if (err) {
|
||||
|
|
|
@ -20,6 +20,8 @@ let libmime = require('libmime');
|
|||
let attachmentCache = new Map();
|
||||
let attachmentCacheSize = 0;
|
||||
|
||||
const mailing_timeout = 5 * 1000;
|
||||
|
||||
function findUnsent(callback) {
|
||||
let returnUnsent = (row, campaign) => {
|
||||
db.getConnection((err, connection) => {
|
||||
|
@ -461,7 +463,6 @@ let sendLoop = () => {
|
|||
}
|
||||
|
||||
let getNext = () => {
|
||||
const mailing_timeout = 5 * 1000;
|
||||
if (!mailer.transport.isIdle()) {
|
||||
// only retrieve new messages if there are free slots in the mailer queue
|
||||
return;
|
||||
|
|
|
@ -11,9 +11,10 @@
|
|||
let moment = require('moment-timezone');
|
||||
let db = require('../lib/db');
|
||||
let log = require('npmlog');
|
||||
|
||||
let lastCheck = false;
|
||||
|
||||
const timezone_timeout = 60 * 60 * 1000;
|
||||
|
||||
function updateTimezoneOffsets(callback) {
|
||||
log.verbose('UTC', 'Updating timezone offsets');
|
||||
db.getConnection((err, connection) => {
|
||||
|
@ -45,7 +46,6 @@ module.exports = callback => {
|
|||
return callback(err);
|
||||
}
|
||||
let checkLoop = () => {
|
||||
const timezone_timeout = 60 * 60 * 1000;
|
||||
let curUtcDate = new Date().toISOString().split('T').shift();
|
||||
if (curUtcDate !== lastCheck) {
|
||||
updateTimezoneOffsets(err => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue