How to use the moment-timezone.default.tz function in moment-timezone

To help you get started, we’ve selected a few moment-timezone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openaq / openaq-fetch / adapters / eea-direct.js View on Github external
const makeDate = (date, timeZone) => {
  // parse date, considering its utc offset
  date = moment.parseZone(date);
  // pass parsed date as a string plus station timeZone offset to generate local time.
  const localDate = moment.tz(date.format(), timeZone);
  // Force local data format to get around issue where +00:00 shows up as Z
  return {
    utc: date.toDate(),
    local: localDate.format('YYYY-MM-DDTHH:mm:ssZ')
  };
};
github openaq / openaq-fetch / adapters / queensland.js View on Github external
var formatData = function (data, source) {
  var $ = cheerio.load(data, {xmlMode: true});

  var dateStr = $('category').attr('measurementdate') + $('category').attr('measurementhour');
  var date = moment.tz(dateStr, 'YYYY-MM-DDHH', 'Australia/Queensland');
  var dates = {utc: date.toDate(), local: date.format()};

  var measurements = [];

  $('measurement').each(function (i, elem) {
    var location = $(this).parent().attr('name');
    var param = renameParameter($(this).attr('name'));

    var m = {
      date: dates,
      parameter: param,
      location: location,
      value: Number($(this).text()),
      unit: getParameterUnit(param),
      city: $(this).parent().parent().attr('name'),
      attribution: [{
github openaq / openaq-fetch / adapters / campania.js View on Github external
const makeDate = (date) => {
  date = moment.tz(date, 'YYYY-MM-DDHH:mm:ss', 'Europe/Malta');
  return {
    utc: date.toDate(),
    local: date.format()
  };
};
github openaq / openaq-fetch / adapters / agaar_mn.js View on Github external
var getDate = function (dateString) {
    var m = moment.tz(dateString, 'YYYY-MM-DD HH:mm', 'Asia/Ulaanbaatar');

    return {utc: m.toDate(), local: m.format()};
  };
github openaq / openaq-fetch / adapters / chile.js View on Github external
var parseDate = function (m) {
    var date = moment.tz(m.date + m.hour, 'YYYY-MM-DDHH:mm', 'America/Santiago');

    return {utc: date.toDate(), local: date.format()};
  };
github openaq / openaq-fetch / adapters / netherlands.js View on Github external
var parseDate = function (string) {
    var date = moment.tz(string, 'YYYYMMDDHHmmss', 'Europe/Amsterdam');

    return {utc: date.toDate(), local: date.format()};
  };
github openaq / openaq-fetch / adapters / envista_za.js View on Github external
const getDate = function (s) {
  const date = moment.tz(s, 'DD/MM/YYYY HH:mm', 'Africa/Johannesburg');
  return {utc: date.toDate(), local: date.format()};
};
github openaq / openaq-fetch / adapters / andalucia.js View on Github external
const makeDate = (date) => {
  date = moment.tz(date, 'DD/MM/YY-hh:mm', 'Europe/Gibraltar');
  return {
    utc: date.toDate(),
    local: date.format()
  };
};
github openaq / openaq-fetch / adapters / arpalazio.js View on Github external
([date1, date2, ...x]) => {
        const timestamp = (averagingPeriod.value === 1)
          ? moment.tz(`${year} ${date1} ${date2}`, 'YYYY DDD HH', timezone)
          : moment.tz(`${year} ${date2}`, 'YYYY DDD', timezone);
        const date = {
          utc: timestamp.toDate(),
          local: timestamp.format()
        };

        const base = {
          date,
          averagingPeriod,
          city: cityName,
          attribution: [{
            name: source.name,
            url: source.sourceURL
          }]
        };

        return x
github openaq / openaq-fetch / adapters / au_act.js View on Github external
var parseDate = function (string) {
    var date = moment.tz(string, 'Australia/Sydney');
    return {utc: date.toDate(), local: date.format()};
  };