1
0
Fork 0
mirror of synced 2024-06-14 16:35:02 +12:00

Fixing issue that was breaking linting.

This commit is contained in:
mike12345567 2021-02-04 10:41:25 +00:00
parent 008c9dcbcd
commit a9dc9f0561

View file

@ -53,7 +53,7 @@ function getContext(thisArg, locals, options) {
return context
}
function initialSteps(str, pattern, options) {
function initialConfig(str, pattern, options) {
if (isOptions(pattern)) {
options = pattern
pattern = null
@ -69,34 +69,34 @@ function initialSteps(str, pattern, options) {
function setLocale(str, pattern, options) {
// if options is null then it'll get updated here
;({ str, pattern, options } = initialSteps(str, pattern, options))
const defaults = { lang: "en", date: new Date(str) }
const opts = getContext(this, defaults, options)
const config = initialConfig(str, pattern, options)
const defaults = { lang: "en", date: new Date(config.str) }
const opts = getContext(this, defaults, config.options)
// set the language to use
dayjs.locale(opts.lang || opts.language)
}
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 (str == null && pattern == null) {
if (config.str == null && config.pattern == null) {
dayjs.locale("en")
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) => {
;({ 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)) {
return duration.format(format)
} else {