Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then((dailyTasks) => {
// if there is an already open session we will store it
// and if it is paused
let now = moment();
let endTime = moment(openWorkSession.endTime);
let endTimeString = endTime.format("h:mm a");
let minutes = Math.round(moment.duration(endTime.diff(now)).asMinutes());
var minutesString = convertMinutesToHoursString(minutes);
let dailyTaskTexts = dailyTasks.map((dailyTask) => {
return dailyTask.dataValues.Task.text;
});
let sessionTasks = commaSeparateOutTaskArray(dailyTaskTexts);
currentSession = {
minutes,
minutesString,
sessionTasks,
endTimeString,
}
// If you've never opened the menu before, then return the last daily batch, else
// create batch for all periods that happened since you last opened it
const startDate = lastOpened ? moment.min(oneWeekPrior, moment(lastOpened)) : oneWeekPrior
return {
start: startDate.toDate(),
end: lastWeeklyReset.toDate(),
};
}
case "realtime":
if (!lastOpened) {
// If set to realtime and never opened before (eg, you just changed the
// setting), default to the last 24 hours.
return {
start: moment().subtract(1, 'days').toDate(),
end: now
}
} else {
return {
start: lastOpened,
end: now
}
}
}
}
timeLabelAsRange(interval, point) {
const timeMoment = moment(point.x * 1000);
const nextMoment = timeMoment.clone().add(interval - 1, 'second');
const format = this.use24Hours() ? 'MMM Do, HH:mm' : 'MMM Do, h:mm a';
// e.g. Aug 23rd, 12:50 pm
return (
<span>
{timeMoment.format(format)}
→
{nextMoment.format(format)}
</span>
);
}
timeLabelAsHour(point) {
const timeMoment = moment(point.x * 1000);
const nextMoment = timeMoment.clone().add(59, 'minute');
const format = this.use24Hours() ? 'HH:mm' : 'LT';
return (
<span>
{timeMoment.format('LL')}
<br>
{timeMoment.format(format)}
→
{nextMoment.format(format)}
</span>
);
}
getFilterParams () {
const statuses = this.state.filter.statuses && this.state.filter.statuses.length
? this.state.filter.statuses
: getStatusForServer(this.props.params.status);
const startDateFrom = this.state.filter.started && this.state.filter.started.length === 1
? moment(this.state.filter.started[0]).utc(false).format('YYYY-MM-DD HH:mm:ss.SSS')
: undefined;
const endDateTo = this.state.filter.completed && this.state.filter.completed.length === 1
? moment(this.state.filter.completed[0]).utc(false).format('YYYY-MM-DD HH:mm:ss.SSS')
: undefined;
const parentId = this.state.filter.parentRunIds && this.state.filter.parentRunIds.length === 1
? this.state.filter.parentRunIds[0] : undefined;
return {
page: this.state.currentPage,
pageSize,
statuses: statuses,
pipelineIds: this.state.filter.pipelineIds,
dockerImages: this.state.filter.dockerImages,
owners: (!this.props.allUsers && this.props.status === 'active' && this.props.authenticatedUserInfo.loaded)
? [this.props.authenticatedUserInfo.value.userName]
: this.state.filter.owners,
startDateFrom,
endDateTo,
parentId,
results.result.forEach((result, key) => {
results.result[key].timeframe.start = moment(result.timeframe.start).tz(results.query.timezone).format(dateFormat);
results.result[key].timeframe.end = moment(result.timeframe.end).tz(results.query.timezone).format(dateFormat);
});
}
export const relativeTime = (timeIn, now) => {
const time = moment(timeIn, "YYYY-MM-DD")
const abs = Math.abs
if (abs(time.diff(now, "days")) >= 1) {
return `${time.diff(now, "days")}d`
} else if (abs(time.diff(now, "hours")) >= 1) {
return `${time.diff(now, "hours")}h`
} else if (abs(time.diff(now, "minutes")) >= 1) {
return `${time.diff(now, "minutes")}m`
}
return `${time.diff(now, "seconds")}s`
}
getMoment() {
return this.now ? moment.unix(this.now) : moment();
}
const wasEarnedToday = earnedDate => {
return moment(earnedDate).isSame(moment(new Date()), 'day')
}