Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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]);
});
});
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];
}
}
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 {
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
render: (text) => <span>{moment.parseZone(text).local().format('YYYY-MM-DD HH:mm')}</span>
},
constructor (value: string, datatype: IRI | null) {
super(value, datatype, null)
this._dateValue = parseZone(value)
}
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})`)
}
}
serialize: (value) => {
return moment.parseZone(value).unix()
},
parseValue: (value) => {
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;
},
});