Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function createDate(dateString, timezone, format) {
if (TIME_WITH_OFFSET_RE.test(dateString)) {
return moment(new Date(dateString));
}
return timezone ?
moment.tz(dateString, format || parseFormat(dateString), timezone) :
moment(dateString, format || parseFormat(dateString));
}
export function createDate(dateString, timezone, format) {
if (TIME_WITH_OFFSET_RE.test(dateString)) {
return moment(new Date(dateString));
}
return timezone ?
moment.tz(dateString, format || parseFormat(dateString), timezone) :
moment(dateString, format || parseFormat(dateString));
}
if (TIME_WITH_OFFSET_RE.test(dateString)) {
return moment(new Date(dateString));
}
if (TIME_AGO_STRING.test(dateString)) {
const fragments = TIME_AGO_STRING.exec(dateString);
return moment().subtract(fragments[1], fragments[2]);
}
if (TIME_NOW_STRING.test(dateString)) {
return moment();
}
return timezone
? moment.tz(dateString, format || parseFormat(dateString), timezone)
: moment(dateString, format || parseFormat(dateString));
}
export function createDate(dateString, timezone, format) {
if (TIME_WITH_OFFSET_RE.test(dateString)) {
return moment(new Date(dateString));
}
if (TIME_AGO_STRING.test(dateString)) {
const fragments = TIME_AGO_STRING.exec(dateString);
return moment().subtract(fragments[1], fragments[2]);
}
if (TIME_NOW_STRING.test(dateString)) {
return moment();
}
return timezone
? moment.tz(dateString, format || parseFormat(dateString), timezone)
: moment(dateString, format || parseFormat(dateString));
}
getMomentFromValue: function(value) {
if (this.config.showDate && this.config.showTime) {
return moment(value, parseFormat(this.config.localeDate) + ' ' + parseFormat(this.config.localeTime));
}
if (this.config.showDate) {
return moment(value, parseFormat(this.config.localeDate));
}
if (this.config.showTime) {
return moment(value, parseFormat(this.config.localeTime));
}
},
getMomentFromValue: function(value) {
if (this.config.showDate && this.config.showTime) {
return moment(value, parseFormat(this.config.localeDate) + ' ' + parseFormat(this.config.localeTime));
}
if (this.config.showDate) {
return moment(value, parseFormat(this.config.localeDate));
}
if (this.config.showTime) {
return moment(value, parseFormat(this.config.localeTime));
}
},