Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return value;
}
if (value.length === 8) {
return toUtc(value, 'YYYYMMDD');
}
if (value.length === 15) {
return toUtc(value, 'YYYYMMDDTHHmmss');
}
// Backward compatibility
if (value.length === 19) {
return toUtc(value, 'YYYY-MM-DD HH:mm:ss');
}
if (!isNaN(value)) {
const epoch = parseInt(value, 10);
return toUtc(epoch);
}
return null;
};
const parseRawTime = (value: any): TimeFragment => {
if (value === null) {
return null;
}
if (value.indexOf('now') !== -1) {
return value;
}
if (value.length === 8) {
return toUtc(value, 'YYYYMMDD');
}
if (value.length === 15) {
return toUtc(value, 'YYYYMMDDTHHmmss');
}
// Backward compatibility
if (value.length === 19) {
return toUtc(value, 'YYYY-MM-DD HH:mm:ss');
}
if (!isNaN(value)) {
const epoch = parseInt(value, 10);
return toUtc(epoch);
}
return null;
};
const parseRawTime = (value: any): TimeFragment => {
if (value === null) {
return null;
}
if (value.indexOf('now') !== -1) {
return value;
}
if (value.length === 8) {
return toUtc(value, 'YYYYMMDD');
}
if (value.length === 15) {
return toUtc(value, 'YYYYMMDDTHHmmss');
}
// Backward compatibility
if (value.length === 19) {
return toUtc(value, 'YYYY-MM-DD HH:mm:ss');
}
if (!isNaN(value)) {
const epoch = parseInt(value, 10);
return toUtc(epoch);
}
return null;
};
shiftTime(e: any, direction: number) {
const range = this.timeRange();
const { from, to } = getShiftedTimeRange(direction, range);
this.setTime({
from: toUtc(from),
to: toUtc(to),
});
}
}
this.scope.$apply(() => {
this.timeSrv.setTime({
from: toUtc(ranges.xaxis.from),
to: toUtc(ranges.xaxis.to),
});
});
}
formatDate(date: DateTimeInput, format?: string) {
date = isDateTime(date) ? date : dateTime(date);
format = format || 'YYYY-MM-DD HH:mm:ss';
const timezone = this.getTimezone();
return timezone === 'browser' ? dateTime(date).format(format) : toUtc(date).format(format);
}
this.scope.$apply(() => {
this.timeSrv.setTime({
from: toUtc(ranges.xaxis.from),
to: toUtc(ranges.xaxis.to),
});
});
}
private parseUrlParam(value: any) {
if (value.indexOf('now') !== -1) {
return value;
}
if (value.length === 8) {
return toUtc(value, 'YYYYMMDD');
}
if (value.length === 15) {
return toUtc(value, 'YYYYMMDDTHHmmss');
}
if (!isNaN(value)) {
const epoch = parseInt(value, 10);
return toUtc(epoch);
}
return null;
}
private parseUrlParam(value: any) {
if (value.indexOf('now') !== -1) {
return value;
}
if (value.length === 8) {
return toUtc(value, 'YYYYMMDD');
}
if (value.length === 15) {
return toUtc(value, 'YYYYMMDDTHHmmss');
}
if (!isNaN(value)) {
const epoch = parseInt(value, 10);
return toUtc(epoch);
}
return null;
}