it('IANA local tz', function (done) { const localTz = moment.tz.guess(); base .createConnection({ timezone: localTz }) .then((conn) => { conn.end(); done(); }) .catch(done); });
// Wait for all queue to resolve Promise.all(queue) .then(() => zip.generateAsync({ type: 'nodebuffer' })) .then((buffer) => { let filename = 'Postleaf Backup (' + Moment.tz('utc').format('YYYY-MM-DD') + ').zip'; // Send zip as a download res.setHeader('Content-Type', 'application/octet-stream'); res.setHeader('Content-disposition', 'attachment; filename="' + filename + '"'); res.end(buffer); }) .catch((err) => next(err));
Promise.all([fetchTZ(location1, utz), fetchTZ(location2, utz)]) .then(([tz1, tz2]) => { const [h1, m1] = moment.tz(tz1).format('Z').split(":").map(e => +e); const [h2, m2] = moment.tz(tz2).format('Z').split(":").map(e => +e); const hDiff = h2 - h1; const mDiff = m2 - m1; return ` ${hDiff > 0 ? getLocation(location2) : getLocation(location1)} is ${pluralize(Math.abs(hDiff), 'hour')} ${mDiff ? ' and ' + pluralize(Math.abs(mDiff), 'minute') : ''} ahead of ${hDiff > 0 ? getLocation(location1) : getLocation(location2)} `; })
function mapRow(row) { return { date: moment.tz(row.a, "YYYY-MM-DD HH:mm", zone).format(), area: row.c.length == 0 ? null : row.c, state: row.z } }
// Get a list of all possible time zones Moment.tz.names().map((zone) => { timeZones.push({ id: zone, name: zone.replace(/_/g, ' ')}); });
function determineOffset(timezone){ var ts = Math.round((new Date()).getTime() / 1000); var min = moment.tz.zone(timezone).utcOffset(1403465838805); var max = moment.tz.zone(timezone).utcOffset(1388563200000); var dstOffset = max - min; var currentOffset = moment.tz.zone(timezone).utcOffset(ts); return {userOffset: currentOffset, userDstOffset: dstOffset}; }
fetchTZ(location, utz) .then(tz => { const now = moment.tz(tz); const [hh, mm, ss] = time.split(':').map(e => +e); return hh === +now.hour() ? ` Yes, it's ${now.format('mm')} minutes past ${now.format('h a')} ${location ? ' in ' + getLocation(location) : ''} ` : ` No, it's ${now.format('h:mm a')} ${location ? ' in ' + getLocation(location) : ''} `; })
let convertToLocalTime = (time) => { return momenttz.tz(time, timeZone).format('LLLL') }
Promise.all([fetchTZ(locationFrom, utz), fetchTZ(locationTo, utz)]) .then(([tzFrom, tzTo]) => { const [hh, mm, ss] = (timeFrom ? timeFrom : moment.tz(tzFrom).format('H:m:s')) .split(':') .map(e => +e); const fromDt = moment.tz(tzFrom).hour(hh).minute(mm); const toDt = moment.tz(tzFrom).hour(hh).minute(mm).tz(tzTo); return `${timeFrom ? 'When it\'s' : 'It\'s'} ${fromDt.format('h:mm a')} in ${getLocation(locationFrom)}, ${timeFrom ? 'it\'s' : 'and'} ${toDt.format('h:mm a')} in ${getLocation(locationTo)} `; })
fetchTZ(location, utz) .then(tz => { const now = moment.tz(tz); return `It's ${now.format('h:mm a')} ${location ? 'in ' + getLocation(location) : ''}`; })
fetchTZ(location, utz) .then(tz => { const date = moment.tz(pars.date, tz); const now = moment.tz(tz); return now.format("MM-DD-YYYY") === date.format("MM-DD-YYYY") ? `Yes, it's ${now.format("MMMM Do YYYY")} ${location ? 'in ' + getLocation(location) : ''} ` : `No, it's ${now.format("MMMM Do YYYY")} ${location ? 'in ' + getLocation(location) : ''} `; })
let getLocalTime = () => { return moment.tz(timeZone).format(); }