This commit is contained in:
Andris Reinman 2016-04-30 18:19:48 +03:00
parent 33f7d7ac8a
commit bc34ed2e39
8 changed files with 43 additions and 17 deletions

View file

@ -1,12 +1,19 @@
'use strict';
// This script re-calculates timezone offsets once a day
// This script re-calculates timezone offsets once a day.
// We need this to be able to send messages using subscriber's local time
// The best option would be to use built-in timezone data of MySQL but
// the availability of timezone data is not guaranteed as it's an optional add on.
// So instead we keep a list of timezone offsets in a table that we can use to
// JOIN with subscription table. Subscription table includes timezone name for
// a subscriber and tzoffset table includes offset from UTC in minutes
let moment = require('moment-timezone');
let db = require('../lib/db');
let lastCheck = false;
let log = require('npmlog');
let lastCheck = false;
function updateTimezoneOffsets(callback) {
log.verbose('UTC', 'Updating timezone offsets');
db.getConnection((err, connection) => {