feat: add utils/date.ts and stores api/user/me
All checks were successful
Build and Deploy Frontend Management to Dev Server / Build Frontend Management Docker Image (push) Successful in 56s
Build and Deploy Frontend Management to Dev Server / Deploy E-learning Frontend Management to Dev Server (push) Successful in 4s
Build and Deploy Frontend Management to Dev Server / Notify Deployment Status (push) Successful in 1s

This commit is contained in:
Missez 2026-03-06 17:33:01 +07:00
parent ea442d7815
commit ae32cfebe4
17 changed files with 199 additions and 275 deletions

View file

@ -0,0 +1,33 @@
/**
* Format a date string into Thai locale format (Date only)
* Example: 10 .. 67
*/
export const formatDate = (date: string | Date | null | undefined): string => {
if (!date) return '-';
const d = typeof date === 'string' ? new Date(date) : date;
return d.toLocaleDateString('th-TH', {
day: 'numeric',
month: 'short',
year: '2-digit'
});
};
/**
* Format a date string into Thai locale format (Date and Time)
* Example: 10 .. 67 14:30
*/
export const formatDateTime = (date: string | Date | null | undefined): string => {
if (!date) return '-';
const d = typeof date === 'string' ? new Date(date) : date;
return d.toLocaleDateString('th-TH', {
day: 'numeric',
month: 'short',
year: '2-digit',
hour: '2-digit',
minute: '2-digit'
});
};