Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static fromMoment( momentInstance ) {
if ( ! moment.isMoment( momentInstance ) ) {
throw new TypeError( 'Requires an instance of moment.' );
}
// this would account for client code that is using `moment` but not
// using `moment-timezone`.
return isFunction( momentInstance.tz ) &&
! isUndefined( momentInstance.tz() ) &&
momentInstance.tz() !== 'UTC' ?
new this(
...this[ privateMethods.normalizeArguments ](
momentInstance.toISOString(),
momentInstance.tz(),
momentInstance.locale()
)
) :
new this(
timeDuration: function() {
var output;
if (moment.isMoment(this.timeStartObject()) && moment.isMoment(this.timeEndObject())) {
output = this.timeEndObject().diff(this.timeStartObject(), 'seconds');
} else if (moment.isMoment(this.timeStartObject())) {
output = moment.utc().diff(this.timeStartObject(), 'seconds');
} else {
output = 0;
}
return output;
},
// Current task duration as human readable format
handleBlur = date => {
const {
patch,
handleBackdropLock,
dispatch,
field,
handleChange,
timeZone,
} = this.props;
const { cache, open } = this.state;
if (!open) {
return;
}
if (date && !MomentTZ.isMoment(date)) {
date = MomentTZ(date, `L LT`);
date = date.tz(timeZone, true);
}
try {
if (
JSON.stringify(cache) !==
(date !== '' ? JSON.stringify(date && date.toDate()) : '')
) {
// calling handleChange manually to update date stored in the MasterWidget
handleChange && handleChange(field, date);
patch(date);
}
} catch (error) {
dispatch(
timeDurationHuman: function() {
var output;
if (moment.isMoment(this.timeStartObject()) && moment.isMoment(this.timeEndObject())) {
output = this.timeStartObject().from(this.timeEndObject(), true);
} else {
output = "";
}
return output;
},
createdAtObject: function () {
static createDate = (fieldValue, fieldType) => {
if (fieldValue) {
return !Moment.isMoment(fieldValue) && fieldValue.match(TIME_REGEX_TEST)
? Moment.utc(Moment.duration(fieldValue).asMilliseconds()).format(
TIME_FORMAT
)
: Moment(fieldValue).format(TableCell.getDateFormat(fieldType));
}
return '';
};
if (repeating.interval) {
if (!isFinite(repeating.interval)) {
throw new Error('`repeating.interval` must be a Number!');
}
c._data.repeating.interval = repeating.interval;
}
if (repeating.until !== undefined) {
if (typeof repeating.until === 'string') {
repeating.until = moment(repeating.until);
}
else if (repeating.until instanceof Date) {
repeating.until = moment(repeating.until);
}
else if (!moment.isMoment(repeating.until)) {
throw new Error('`repeating.until` must be a Date or a moment object!');
}
if (!repeating.until.isValid()) {
throw new Error('`repeating.until` has to be a valid date!');
}
c._data.repeating.until = repeating.until;
}
if (repeating.byDay) {
if (!Array.isArray(repeating.byDay)) {
repeating.byDay = [repeating.byDay];
}
c._data.repeating.byDay = [];
export function generateMomentObj(value, FORMAT) {
if (Moment.isMoment(value)) {
return value.format(FORMAT);
}
return value ? Moment(value).format(FORMAT) : null;
}
export function parseDateWithCurrentTimezone(value) {
if (value) {
if (Moment.isMoment(value)) {
return value;
}
value = convertTimeStringToMoment(value);
return Moment(value);
}
return '';
}
_.each(data.tasks, function(task) {
task.type = _.find(data.types, function(type) {
return type.id === task.typeId;
});
task.user = _.find(data.users, function(user) {
return user.id === task.userId;
});
task.phase = _.find(data.phases, function(phase) {
return phase.id === task.phaseId;
});
task.timeStartObjectUser = moment.isMoment(task.timeStartObject())
? task.timeStartObject().tz(request.user.momentTimezone) : null;
task.timeEndObjectUser = moment.isMoment(task.timeEndObject())
? task.timeEndObject().tz(request.user.momentTimezone) : null;
});