Merge pull request #458 from shariquerik/dayjs
fix: Replaced luxon with dayjs
This commit is contained in:
commit
b9c43df357
@ -14,7 +14,7 @@
|
|||||||
"@vueuse/core": "^10.3.0",
|
"@vueuse/core": "^10.3.0",
|
||||||
"@vueuse/integrations": "^10.3.0",
|
"@vueuse/integrations": "^10.3.0",
|
||||||
"feather-icons": "^4.28.0",
|
"feather-icons": "^4.28.0",
|
||||||
"frappe-ui": "^0.1.89",
|
"frappe-ui": "^0.1.90",
|
||||||
"gemoji": "^8.1.0",
|
"gemoji": "^8.1.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"mime": "^4.0.1",
|
"mime": "^4.0.1",
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { Dialogs } from '@/utils/dialogs'
|
import { Dialogs } from '@/utils/dialogs'
|
||||||
import { sessionStore as session } from '@/stores/session'
|
import { sessionStore as session } from '@/stores/session'
|
||||||
import { Toasts } from 'frappe-ui'
|
import { Toasts, setConfig } from 'frappe-ui'
|
||||||
import { computed, defineAsyncComponent } from 'vue'
|
import { computed, defineAsyncComponent } from 'vue'
|
||||||
|
|
||||||
const MobileLayout = defineAsyncComponent(
|
const MobileLayout = defineAsyncComponent(
|
||||||
@ -25,4 +25,7 @@ const Layout = computed(() => {
|
|||||||
return DesktopLayout
|
return DesktopLayout
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
setConfig('systemTimezone', window.timezone?.system || null)
|
||||||
|
setConfig('localTimezone', window.timezone?.user || null)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -56,7 +56,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center flex-wrap gap-2">
|
<div class="flex items-center flex-wrap gap-2">
|
||||||
<Badge :label="formatDate(activity.creation, 'MMM d, EEEE')">
|
<Badge :label="formatDate(activity.creation, 'MMM D, dddd')">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<CalendarIcon class="size-3" />
|
<CalendarIcon class="size-3" />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -19,11 +19,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="task.due_date">
|
<div v-if="task.due_date">
|
||||||
<Tooltip
|
<Tooltip
|
||||||
:text="formatDate(task.due_date, 'EEE, MMM d, yyyy | hh:mm a')"
|
:text="formatDate(task.due_date, 'ddd, MMM D, YYYY | hh:mm a')"
|
||||||
>
|
>
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<CalendarIcon />
|
<CalendarIcon />
|
||||||
<div>{{ formatDate(task.due_date, 'd MMM, hh:mm a') }}</div>
|
<div>{{ formatDate(task.due_date, 'D MMM, hh:mm a') }}</div>
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -127,7 +127,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="-mb-1 flex shrink-0 items-end gap-1 text-ink-gray-5">
|
<div class="-mb-1 flex shrink-0 items-end gap-1 text-ink-gray-5">
|
||||||
<Tooltip :text="formatDate(whatsapp.creation, 'EEE, MMM d, yyyy')">
|
<Tooltip :text="formatDate(whatsapp.creation, 'ddd, MMM D, YYYY')">
|
||||||
<div class="text-2xs">
|
<div class="text-2xs">
|
||||||
{{ formatDate(whatsapp.creation, 'hh:mm a') }}
|
{{ formatDate(whatsapp.creation, 'hh:mm a') }}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -242,7 +242,7 @@ function captureImage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function uploadViaCamera() {
|
function uploadViaCamera() {
|
||||||
const nowDatetime = formatDate(new Date(), 'yyyy_MM_dd_HH_mm_ss')
|
const nowDatetime = formatDate(new Date(), 'YYYY_MM_DD_HH_mm_ss')
|
||||||
let filename = `capture_${nowDatetime}.png`
|
let filename = `capture_${nowDatetime}.png`
|
||||||
urlToFile(cameraImage.value, filename, 'image/png').then((file) => {
|
urlToFile(cameraImage.value, filename, 'image/png').then((file) => {
|
||||||
addFiles([file])
|
addFiles([file])
|
||||||
|
|||||||
@ -40,12 +40,12 @@
|
|||||||
>
|
>
|
||||||
<div v-if="column.key === 'due_date'">
|
<div v-if="column.key === 'due_date'">
|
||||||
<Tooltip
|
<Tooltip
|
||||||
:text="item && formatDate(item, 'EEE, MMM d, yyyy | hh:mm a')"
|
:text="item && formatDate(item, 'ddd, MMM D, YYYY | hh:mm a')"
|
||||||
>
|
>
|
||||||
<div class="flex items-center gap-2 truncate text-base">
|
<div class="flex items-center gap-2 truncate text-base">
|
||||||
<div><CalendarIcon /></div>
|
<div><CalendarIcon /></div>
|
||||||
<div v-if="item" class="truncate">
|
<div v-if="item" class="truncate">
|
||||||
{{ formatDate(item, 'd MMM, hh:mm a') }}
|
{{ formatDate(item, 'D MMM, hh:mm a') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@ -266,7 +266,7 @@ function parseRows(rows, columns = []) {
|
|||||||
if (
|
if (
|
||||||
fieldType &&
|
fieldType &&
|
||||||
['Date', 'Datetime'].includes(fieldType) &&
|
['Date', 'Datetime'].includes(fieldType) &&
|
||||||
!['modified', 'creation'].includes(row)
|
!['modified', 'creation', 'due_date'].includes(row)
|
||||||
) {
|
) {
|
||||||
_rows[row] = formatDate(task[row], '', true, fieldType == 'Datetime')
|
_rows[row] = formatDate(task[row], '', true, fieldType == 'Datetime')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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