fix: replaced luxon with dayjs
This commit is contained in:
parent
f214890146
commit
641d66bb14
@ -3,7 +3,7 @@ import TaskPriorityIcon from '@/components/Icons/TaskPriorityIcon.vue'
|
|||||||
import { usersStore } from '@/stores/users'
|
import { usersStore } from '@/stores/users'
|
||||||
import { gemoji } from 'gemoji'
|
import { gemoji } from 'gemoji'
|
||||||
import { useTimeAgo } from '@vueuse/core'
|
import { useTimeAgo } from '@vueuse/core'
|
||||||
import { toast, convertToUserTimezone, luxonDate } from 'frappe-ui'
|
import { toast, dayjsLocal, dayjs } from 'frappe-ui'
|
||||||
import { h } from 'vue'
|
import { h } from 'vue'
|
||||||
|
|
||||||
export function createToast(options) {
|
export function createToast(options) {
|
||||||
@ -39,8 +39,9 @@ export function formatTime(seconds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function formatDate(date, format, onlyDate = false, onlyTime = false) {
|
export function formatDate(date, format, onlyDate = false, onlyTime = false) {
|
||||||
|
if (!date) return ''
|
||||||
format = getFormat(date, format, onlyDate, onlyTime, false)
|
format = getFormat(date, format, onlyDate, onlyTime, false)
|
||||||
return convertToUserTimezone(date, format)
|
return dayjsLocal(date).format(format)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFormat(
|
export function getFormat(
|
||||||
@ -52,16 +53,19 @@ export function getFormat(
|
|||||||
) {
|
) {
|
||||||
if (!date) return ''
|
if (!date) return ''
|
||||||
let dateFormat =
|
let dateFormat =
|
||||||
window.sysdefaults.date_format.replace('mm', 'MM') || 'yyyy-MM-dd'
|
window.sysdefaults.date_format
|
||||||
|
.replace('mm', 'MM')
|
||||||
|
.replace('yyyy', 'YYYY')
|
||||||
|
.replace('dd', 'DD') || 'YYYY-MM-DD'
|
||||||
let timeFormat = window.sysdefaults.time_format || 'HH:mm:ss'
|
let timeFormat = window.sysdefaults.time_format || 'HH:mm:ss'
|
||||||
format = format || 'EEE, MMM d, yyyy h:mm a'
|
format = format || 'ddd, MMM d, YYYY h:mm a'
|
||||||
|
|
||||||
if (onlyDate) format = dateFormat
|
if (onlyDate) format = dateFormat
|
||||||
if (onlyTime) format = timeFormat
|
if (onlyTime) format = timeFormat
|
||||||
if (onlyTime && onlyDate) format = `${dateFormat} ${timeFormat}`
|
if (onlyTime && onlyDate) format = `${dateFormat} ${timeFormat}`
|
||||||
|
|
||||||
if (withDate) {
|
if (withDate) {
|
||||||
return luxonDate(date).toFormat(format)
|
return dayjs(date).format(format)
|
||||||
}
|
}
|
||||||
return format
|
return format
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user