Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log("all work sessions:");
console.log(workSessions);
var endTime = moment();
// IF you chose a new task not on your list to have completed
if (differentCompletedTask) {
var minutes; // calculate time worked on that task
if (workSessions.length > 0) {
// use this to get how long the
// custom added task took
var startSession = workSessions[0];
var startTime = moment(startSession.startTime);
minutes = moment.duration(endTime.diff(startTime)).asMinutes();
} else {
// this should never happen.
minutes = 30; // but if it does... default minutes duration
}
// create new task that the user just got done
user.getDailyTasks({
where: [ `"DailyTask"."type" = ?`, "live" ]
})
.then((dailyTasks) => {
const priority = dailyTasks.length+1;
const text = differentCompletedTask;
// record the different completed task
models.Task.create({
text,
normalize() {
// XXX momentjs behaves badly with durations having
// floating-point days, so be sure we always give integer days
// until we get a straight answer from the momentjs crew. This
// is a narrow fix for a narrow bug, non-day units are not a problem.
if (!this.duration) {
return ;
}
var floatdays = this.duration.days();
var days = (floatdays >= 0)? Math.floor(floatdays) : Math.ceil(floatdays);
if (floatdays === days) {
return ;
}
this.duration.subtract(moment.duration({days: floatdays - days}));
this.duration.add(moment.duration({milliseconds:(floatdays - days) * 86400 * 1000}));
}
callback: (response, convo) => {
let now = moment().tz(tz);
let { intentObject: { entities } } = response;
// for time to tasks, these wit intents are the only ones that makes sense
let customTimeObject = witTimeResponseToTimeZoneObject(response, tz);
if (customTimeObject) {
let minutes = Math.round(moment.duration(customTimeObject.diff(now)).asMinutes());
convo.sessionStart.minutes = minutes;
finalizeSessionTimeAndContent(convo);
convo.next();
} else {
// invalid
convo.say("I'm sorry, I didn't catch that :dog:");
let question = `How much more time did you want to add to \`${content}\` today?`;
convo.repeat();
}
convo.next();
}
}
it('setter should work with moment.duration', function () {
const a = new ICalAlarm(null, new ICalEvent(null, new ICalCalendar()));
a.triggerBefore(moment.duration(2, 'minutes'));
assert.strictEqual(a._data.trigger, -120);
});
week: () => moment.duration(1, 'weeks'),
month: () => moment.duration(1, 'months'),
_onChargingChange = () => {
const changeTime = Date.now();
Actions.recordUserEvent('Battery State Changed', {
oldState: this.isBatteryCharging() ? 'battery' : 'ac',
oldStateDuration: Math.min(
changeTime - this._lastChangeTime,
moment.duration(12, 'hours').asMilliseconds()
),
});
this._lastChangeTime = changeTime;
this._callbacks.forEach(cb => cb());
};
clone() {
return new JuttleMoment({
duration: this.duration && moment.duration(this.duration),
moment: this.moment && this.moment.clone()
});
}
callback: function(response, convo) {
let { intentObject: { entities } } = response;
let now = moment().tz(tz);
let customTimeObject = witTimeResponseToTimeZoneObject(response, tz);
if (customTimeObject) {
let minutes = Math.round(moment.duration(customTimeObject.diff(now)).asMinutes());
convo.sessionStart.calculatedTimeObject = customTimeObject;
convo.sessionStart.minutes = minutes;
convo.sessionStart.confirmStart = true;
convo.next();
} else {
convo.say("I didn't quite get that :thinking_face:");
convo.repeat();
convo.next();
}
}
}
export function getTimeUntil(
time: Dateish,
currentTime?: Dateish = moment()
): moment$MomentDuration {
return moment.duration(getTimeDifference(time, currentTime), 'milliseconds');
}