esoftplay 0.0.167 → 0.0.168
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/moment.ts +12 -25
- package/package.json +1 -1
package/moment.ts
CHANGED
|
@@ -8,8 +8,6 @@ const utc = require('dayjs/plugin/utc')
|
|
|
8
8
|
const timezone = require('dayjs/plugin/timezone') // dependent on utc plugin
|
|
9
9
|
const relativeTime = require('dayjs/plugin/relativeTime')
|
|
10
10
|
var duration = require('dayjs/plugin/duration')
|
|
11
|
-
const localeData = require('dayjs/plugin/localeData')
|
|
12
|
-
dayjs.extend(localeData)
|
|
13
11
|
dayjs.extend(duration)
|
|
14
12
|
dayjs.extend(utc)
|
|
15
13
|
dayjs.extend(timezone)
|
|
@@ -91,50 +89,39 @@ export default function moment(date?: string | Date | any) {
|
|
|
91
89
|
require('dayjs/locale/en')
|
|
92
90
|
require('dayjs/locale/id')
|
|
93
91
|
require('dayjs/locale/zh-cn')
|
|
94
|
-
|
|
95
|
-
const out = dayjs(_date).locale(locale_id)
|
|
92
|
+
const out = dayjs.locale(locale_id)
|
|
96
93
|
return moment(out)
|
|
97
94
|
},
|
|
98
95
|
/* last chain */
|
|
99
96
|
fromNow: () => {
|
|
100
97
|
const currentLang = esp.modProp('lib/locale').default.state().get()
|
|
101
98
|
const localeId = langData?.filter?.((x) => x.name == currentLang)?.[0]?.code
|
|
102
|
-
|
|
103
|
-
const out = dayjs(resetTimeOffset(_date)).
|
|
99
|
+
moment().locale(localeId)
|
|
100
|
+
const out = dayjs(resetTimeOffset(_date)).fromNow()
|
|
104
101
|
return out
|
|
105
102
|
},
|
|
106
103
|
format: (custom: string, ignoreTimezone?: boolean) => {
|
|
107
104
|
const currentLang = esp.modProp('lib/locale').default.state().get()
|
|
108
|
-
const localeId = langData?.filter?.((x) => x.name == currentLang)?.[0]?.code
|
|
109
|
-
|
|
110
|
-
require(`dayjs/locale/${localeId}`)
|
|
111
|
-
} catch (e) {
|
|
112
|
-
}
|
|
105
|
+
const localeId = langData?.filter?.((x) => x.name == currentLang)?.[0]?.code
|
|
106
|
+
moment().locale(localeId)
|
|
113
107
|
const _d = ignoreTimezone ? _date : resetTimeOffset(_date)
|
|
114
|
-
|
|
115
|
-
const out = dayjs(_d).locale(localeId).format(custom)
|
|
108
|
+
const out = dayjs(_d).format(custom)
|
|
116
109
|
return out
|
|
117
110
|
},
|
|
118
111
|
serverFormat: (custom: string) => {
|
|
119
112
|
const currentLang = esp.modProp('lib/locale').default.state().get()
|
|
120
|
-
const localeId = langData?.filter?.((x) => x.name == currentLang)?.[0]?.code
|
|
121
|
-
|
|
122
|
-
require(`dayjs/locale/${localeId}`)
|
|
123
|
-
} catch (e) {
|
|
124
|
-
}
|
|
113
|
+
const localeId = langData?.filter?.((x) => x.name == currentLang)?.[0]?.code
|
|
114
|
+
moment().locale(localeId)
|
|
125
115
|
const _d = resetTimeOffset(_date)
|
|
126
|
-
const out = dayjs(_d).
|
|
116
|
+
const out = dayjs(_d).format(custom)
|
|
127
117
|
return out
|
|
128
118
|
},
|
|
129
119
|
localeFormat: (custom: string, ignoreTimezone?: boolean) => {
|
|
130
120
|
const currentLang = esp.modProp('lib/locale').default.state().get()
|
|
131
|
-
const localeId = langData?.filter?.((x) => x.name == currentLang)?.[0]?.code
|
|
132
|
-
|
|
133
|
-
require(`dayjs/locale/${localeId}`)
|
|
134
|
-
} catch (e) {
|
|
135
|
-
}
|
|
121
|
+
const localeId = langData?.filter?.((x) => x.name == currentLang)?.[0]?.code
|
|
122
|
+
moment().locale(localeId)
|
|
136
123
|
const _d = _date
|
|
137
|
-
const out = dayjs(_d).
|
|
124
|
+
const out = dayjs(_d).format(custom)
|
|
138
125
|
return out
|
|
139
126
|
},
|
|
140
127
|
toDate: () => {
|