Fixing issue that was breaking linting.
This commit is contained in:
parent
1a9d6bcb60
commit
5a7c0c1cc1
|
@ -53,7 +53,7 @@ function getContext(thisArg, locals, options) {
|
||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
|
||||||
function initialSteps(str, pattern, options) {
|
function initialConfig(str, pattern, options) {
|
||||||
if (isOptions(pattern)) {
|
if (isOptions(pattern)) {
|
||||||
options = pattern
|
options = pattern
|
||||||
pattern = null
|
pattern = null
|
||||||
|
@ -69,34 +69,34 @@ function initialSteps(str, pattern, options) {
|
||||||
|
|
||||||
function setLocale(str, pattern, options) {
|
function setLocale(str, pattern, options) {
|
||||||
// if options is null then it'll get updated here
|
// if options is null then it'll get updated here
|
||||||
;({ str, pattern, options } = initialSteps(str, pattern, options))
|
const config = initialConfig(str, pattern, options)
|
||||||
const defaults = { lang: "en", date: new Date(str) }
|
const defaults = { lang: "en", date: new Date(config.str) }
|
||||||
const opts = getContext(this, defaults, options)
|
const opts = getContext(this, defaults, config.options)
|
||||||
|
|
||||||
// set the language to use
|
// set the language to use
|
||||||
dayjs.locale(opts.lang || opts.language)
|
dayjs.locale(opts.lang || opts.language)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.date = (str, pattern, options) => {
|
module.exports.date = (str, pattern, options) => {
|
||||||
;({ str, pattern, options } = initialSteps(str, pattern, options))
|
const config = initialConfig(str, pattern, options)
|
||||||
|
|
||||||
// if no args are passed, return a formatted date
|
// if no args are passed, return a formatted date
|
||||||
if (str == null && pattern == null) {
|
if (config.str == null && config.pattern == null) {
|
||||||
dayjs.locale("en")
|
dayjs.locale("en")
|
||||||
return dayjs().format("MMMM DD, YYYY")
|
return dayjs().format("MMMM DD, YYYY")
|
||||||
}
|
}
|
||||||
|
|
||||||
setLocale(str, pattern, options)
|
setLocale(config.str, config.pattern, config.options)
|
||||||
|
|
||||||
return dayjs(new Date(str)).format(pattern)
|
return dayjs(new Date(config.str)).format(config.pattern)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.duration = (str, pattern, format) => {
|
module.exports.duration = (str, pattern, format) => {
|
||||||
;({ str, pattern } = initialSteps(str, pattern))
|
const config = initialConfig(str, pattern)
|
||||||
|
|
||||||
setLocale(str, pattern)
|
setLocale(config.str, config.pattern)
|
||||||
|
|
||||||
const duration = dayjs.duration(str, pattern)
|
const duration = dayjs.duration(config.str, config.pattern)
|
||||||
if (!isOptions(format)) {
|
if (!isOptions(format)) {
|
||||||
return duration.format(format)
|
return duration.format(format)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue