refactor(front) : formatDateFr mutualisé dans shared/utils/date + rendu déterministe (ERP-191)
Trois copies identiques de formatDateFr (logistique weighingTicketFormat, transport carriers/index, CarrierQualimatTab) fusionnées en un seul helper partagé. La nouvelle version lit la date directement dans la chaîne ISO (10 premiers caractères) au lieu de new Date(value).getDate() : un datetime porteur d'un offset (…+02:00, …Z) ne bascule plus d'un jour selon le fuseau du navigateur / runner CI, et reste cohérent avec l'écran d'édition (slice) et l'export serveur (format d/m/Y). weighingTicketFormat ré-exporte le helper (imports inchangés côté écrans). Tests de déterminisme fuseau ajoutés dans shared/utils/date.test.ts.
This commit is contained in:
@@ -141,6 +141,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { formatDateFr } from '~/shared/utils/date'
|
||||
|
||||
interface FilterOption {
|
||||
value: string
|
||||
@@ -235,20 +236,6 @@ function isValidityExpired(item: Record<string, unknown>): boolean {
|
||||
return date.getTime() < today.getTime()
|
||||
}
|
||||
|
||||
/** Format court francais JJ-MM-AAAA (spec M4). Chaine vide si date absente / invalide. */
|
||||
function formatDateFr(value: string | null | undefined): string {
|
||||
if (!value) {
|
||||
return ''
|
||||
}
|
||||
const date = new Date(value)
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return ''
|
||||
}
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
return `${day}-${month}-${date.getFullYear()}`
|
||||
}
|
||||
|
||||
/** Clic sur une ligne → ecran Consultation (route a plat /carriers/{id}). */
|
||||
function onRowClick(item: Record<string, unknown>): void {
|
||||
router.push(`/carriers/${item.id}`)
|
||||
|
||||
Reference in New Issue
Block a user