How to use the moment.parseZone function in moment

To help you get started, we’ve selected a few moment 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 flow-typed / flow-typed / definitions / npm / moment_v2.x.x / test_moment-v2.js View on Github external
it('is invalid to use special, undocumented formats', () => {
    // The following cases do generate valid moment objects, but this
    // seems to be an undocumented API. If the moment project decides to
    // document some of these APIs, then the types can be changed.

    // $ExpectError
    moment.parseZone(new Date());
    // $ExpectError
    moment.parseZone(moment());
    // $ExpectError
    moment.parseZone({ hour: 15, minute: 10 });
    // $ExpectError
    moment.parseZone(1318781876406);
    // $ExpectError
    moment.parseZone([2015, 0]);
  });
});
github numenta / numenta-apps / unicorn / app / common / timestamp.js View on Github external
export function parseIsoTimestampFallbackUtc(timestamp) {
  // If it contains a '+' or '-' or 'Z' after the 'T', it has time zone info.
  let hasTimeZone = /.*T.*(\+|\-|Z).*/.test(timestamp);

  let m;
  if (hasTimeZone) {
    m = moment.parseZone(timestamp);
  } else {
    m = moment.utc(timestamp);
  }

  return [m, hasTimeZone];
}
github kpiwko / jira-miner / lib / jira / normalizer.js View on Github external
}

  switch(fieldSchema.schema.type) {
    case 'user':
      return value ? value.displayName : null
    case 'array':
      return value ? value.map(v => {
        return extractValueFromField( {
          schema: {
            type: fieldSchema.schema.items
          }
        }, v)
      }) : []
    case 'datetime':
    case 'date':
        return value ? moment.parseZone(value) : null
    case 'project':
    case 'priority':
    case 'status':
    case 'resolution':
    case 'issuetype':
    case 'component':
    case 'version':
      return value ? value.name : null
    case 'issuelinks':
      return value ? (() => {
        // figure out what kind of issuelink we are processing
        let link
        if(!!!value.inwardIssue && !!!value.outwardIssue) {
          link = value
        }
        else {
github glennjones / text-autolinker / lib / autolinker.js View on Github external
data[x].start.impliedComponents = [];
			}

			if (options.publishedDate || (
				data[x].start.impliedComponents.indexOf('day') === -1 && data[x].start.impliedComponents.indexOf('month') === -1 && constainRestrictedWords(data[x].text) === false
			)) {



				if (data[x].start.timezoneOffset) {
					// add timezone text parse to text based local time 
					iso = buildISOLocalDate(data[x].start) + moment('2014-01-01:00:00:00').zone(data[x].start.timezoneOffset).format('Z');
				} else {
					if (options.publishedDate && moment.parseZone(options.publishedDate).zone() !== 0) {
						// add timezone from to publishedDate to text based local time
						iso = buildISOLocalDate(data[x].start) + moment.parseZone(options.publishedDate).format('Z');
					} else {
						// localtime
						iso = buildISOLocalDate(data[x].start);
					}
				}

				// correct tomorrow issue
				if(data[x].text.toLowerCase().indexOf('tomorrow') > -1){
					var today = new Date(options.publishedDate);
					today.setDate(today.getDate() + 1);
					// correct data
					data[x].start.year = today.getFullYear();
					data[x].start.month = today.getMonth();
					data[x].start.day = today.getDate();
					data[x].startDate = today.toISOString();
					// correct iso
github yvanwangl / AccountSystem / src / components / Settlement / SettlementList / SettlementList.jsx View on Github external
				render: (text) =&gt; <span>{moment.parseZone(text).local().format('YYYY-MM-DD HH:mm')}</span>
			},
github Callidon / sparql-engine / src / rdf / literals.ts View on Github external
constructor (value: string, datatype: IRI | null) {
    super(value, datatype, null)
    this._dateValue = parseZone(value)
  }
github Callidon / sparql-engine / src / rdf-terms.js View on Github external
function termToJS (value, type) {
  switch (type) {
    case 'http://www.w3.org/2001/XMLSchema#string':
      return value
    case 'http://www.w3.org/2001/XMLSchema#integer':
    case 'http://www.w3.org/2001/XMLSchema#number':
    case 'http://www.w3.org/2001/XMLSchema#float':
    case 'http://www.w3.org/2001/XMLSchema#decimal':
    case 'http://www.w3.org/2001/XMLSchema#double':
      return Number(value)
    case 'http://www.w3.org/2001/XMLSchema#boolean':
      return value === '"true"'
    case 'http://www.w3.org/2001/XMLSchema#dateTime':
      return moment.parseZone(value)
    default:
      throw new Error(`Unknown Datatype found during RDF Term parsing: ${value} (datatype: ${type})`)
  }
}
github mfix22 / gnt / packages / unix-date / index.js View on Github external
serialize: (value) => {
    return moment.parseZone(value).unix()
  },
  parseValue: (value) => {
github opencollective / opencollective-api / server / graphql / v1 / types.js View on Github external
parseLiteral: ast => {
    if (ast.kind !== Kind.STRING) {
      throw new GraphQLError(`Query error: Can only parse strings got a: ${ast.kind}`);
    }

    const date = moment.parseZone(ast.value);
    if (!date.isValid()) {
      throw new GraphQLError('Query error: unable to pass date string. Expected a valid ISO-8601 date string.');
    }
    return date;
  },
});