All files / src/composables useDateFormat.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 4/4
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25                          799x   799x   589x   361x   166x      
/**
 * Date formatting bound to the user's UI language.
 * See utils/dateFormat.ts for the formatting rules.
 */
import { useUILanguage } from './useUILanguage'
import {
  formatDate as formatDateFor,
  formatDateTime as formatDateTimeFor,
  formatRelative as formatRelativeFor,
  type DateInput
} from '@/utils/dateFormat'
 
export function useDateFormat() {
  const { uiLanguage } = useUILanguage()
 
  return {
    /** Day only: "13 nov. 2026" */
    formatDate: (value: DateInput) => formatDateFor(value, uiLanguage.value),
    /** Day and time: "13 nov. 2026, 15:42" */
    formatDateTime: (value: DateInput) => formatDateTimeFor(value, uiLanguage.value),
    /** Recent social content: "il y a 5 minutes"; full date+time after a week */
    formatRelative: (value: DateInput) => formatRelativeFor(value, uiLanguage.value)
  }
}