fix:bug format datjs

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-11-05 12:20:38 +07:00
parent da3e47d8b9
commit b43a55719a
3 changed files with 4 additions and 4 deletions

View file

@ -12,7 +12,7 @@ export const load: PageServerLoad = async ({ fetch }) => {
exams.forEach((ex) => {
const { id, title, announcement_startDate } = ex;
const url = '/competitive/' + id;
ex.date = dayjs(announcement_startDate).format('DD MMM BBBB');
ex.date = dayjs(announcement_startDate).format('DD MMM YYYY');
ex.image = ex.image ? ex.image : '/images/exam_place_holder.png';
if (!ex.announcementExam) return; //ignore other date for normal post

View file

@ -12,7 +12,7 @@ export const load: PageServerLoad = async ({ fetch }) => {
exams.forEach((ex) => {
const { id, title, announcement_startDate } = ex;
const url = '/qualifying/' + id;
ex.date = dayjs(announcement_startDate).format('DD MMM BBBB');
ex.date = dayjs(announcement_startDate).format('DD MMM YYYY');
ex.image = ex.image ? ex.image : '/images/exam_place_holder.png';
if (!ex.announcementExam) return; //ignore other date for normal post

View file

@ -7,8 +7,8 @@
import dayjs from 'dayjs';
import { each } from 'svelte/internal';
function formatDate(start: string, end: string | undefined = undefined) {
if (!end) return dayjs(start).format('DD MMM BBBB');
return dayjs(start).format('DD MMM BBBB') + ' - ' + dayjs(end).format('DD MMM BBBB');
if (!end) return dayjs(start).format('DD MMM YYYY');
return dayjs(start).format('DD MMM YYYY') + ' - ' + dayjs(end).format('DD MMM YYYY');
}
function isEndDatePassed(endDate: string | undefined) {
if (endDate) {