Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
values.forEach(function (value) {
if (moment(value, moment.ISO_8601).isValid()) {
// "2016-08-17 17:25:00+01"
mytype.datetime++;
} else if (
(moment.duration(value).asMilliseconds() !== 0) &&
(typeof value === 'string') &&
(value[0].toLowerCase() === 'p')) {
// "P10Y"
mytype.duration++;
} else if (value == +value) { // eslint-disable-line eqeqeq
// "10" or 10
mytype.continuous++;
} else {
// "hello world"
mytype.categorial++;
}
});
parser: function (label) {
return moment(label, moment.ISO_8601);
}
}
parser: function (label) {
return moment(label, moment.ISO_8601);
}
}
@Input() id: string = `datetime-${++nextId}`;
@Input() name: string;
@Input() disabled: boolean;
@Input() tabindex: number;
@Input() autofocus: boolean = false;
@Input() label: string;
@Input() hint: string;
@Input() placeholder: string = '';
@Input() minDate: string | Date;
@Input() maxDate: string | Date;
@Input() precision: moment.unitOfTime.StartOf;
@Input() timezone: string;
@Input() inputFormats: any[] = ['L', `LT`, 'L LT', moment.ISO_8601];
@Input()
get inputType(): string {
if (!this._inputType) {
return DateTimeType.date;
}
return this._inputType;
}
set inputType(val: string) {
this._inputType = val;
this.displayValue = this.getDisplayValue();
}
@Input()
get format(): string {
if (!this._format) {
formatDate(date: string) {
const dateInMoment = moment(date, moment.ISO_8601).tz(moment.tz.guess(true))
const format = dateInMoment.minutes() === 0 ? "MMM D, h A" : "MMM D, h:mm A"
return dateInMoment.format(format)
}
check: (v) => moment(v, moment.ISO_8601).isValid(),
hydrate: (txt) => types.fn('parse_iso', txt)
const apiTz = api && api.config && api.config.timezone ? api.config.timezone : 'UTC';
const defaultStoredTz =
api && api.config && api.config.defaultStoredTimezone ? api.config.defaultStoredTimezone : apiTz;
const storedTz =
options && options.storedType && options.storedType.options && options.storedType.options.timezone
? options.storedType.options.timezone
: defaultStoredTz;
if (!moment.tz.zone(storedTz)) throw new ImplementationError(`Invalid timezone: "${storedTz}"`);
let m;
if (options && options.storedType && options.storedType.type === 'unixtime') {
m = moment(parseInt(value, 10), 'X');
} else {
m = moment.tz(value, moment.ISO_8601, true, storedTz);
}
if (!m.isValid()) throw new DataError('Invalid date format');
return m;
}
_getAcceptedFormats: function() {
return [
momentHelper.DATE_FORMAT_TZ,
momentHelper.DATE_FORMAT_TZ_NO_MS,
moment.ISO_8601,
momentHelper.DATE_FORMAT,
momentHelper.DATE_FORMAT_NO_MS
];
},
var parse = function(str){
return parse_utc
? moment.utc(str, moment.ISO_8601)
: moment(str, moment.ISO_8601);
};
var d = parse(date_str);
}
try {
let recentSessions = await db.getRecentSessionsWithInstallationId(req.params.installationId)
let currentInstallation = await db.getInstallationWithInstallationId(req.params.installationId)
let allInstallations = await db.getInstallations()
let viewParams = {
recentSessions: [],
currentInstallationName: currentInstallation.name,
installations: allInstallations.map(installation => { return { name: installation.name, id: installation.id }})
}
for(const recentSession of recentSessions) {
let createdAt = moment(recentSession.createdAt, moment.ISO_8601)
let updatedAt = moment(recentSession.updatedAt, moment.ISO_8601)
viewParams.recentSessions.push({
unit: recentSession.unit,
createdAt: createdAt.tz('America/Vancouver').format('DD MMM Y, hh:mm:ss A'),
updatedAt: updatedAt.tz('America/Vancouver').format('DD MMM Y, hh:mm:ss A'),
state: recentSession.state,
numPresses: recentSession.numPresses.toString(),
incidentType: recentSession.incidentType,
notes: recentSession.notes
})
}
for(let i=0; i