refactor(front) : formatDateFr mutualisé dans shared/utils/date + rendu déterministe (ERP-191)
Pull Request — Quality gate / Frontend (lint + Vitest + build) (pull_request) Successful in 1m33s
Pull Request — Quality gate / Backend (PHP CS + PHPUnit) (pull_request) Successful in 5m19s

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:
2026-06-24 16:22:28 +02:00
parent 9b476f22bb
commit 87513d130a
5 changed files with 50 additions and 45 deletions
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { computed, ref, watch } from 'vue'
import { debounce } from '~/shared/utils/debounce'
import { formatDateFr } from '~/shared/utils/date'
import { useQualimatSearch, type QualimatCarrierRow } from '~/modules/transport/composables/useQualimatSearch'
/**
@@ -92,19 +93,6 @@ function isExpired(value: string): boolean {
return date.getTime() < today.getTime()
}
/** Format court français JJ-MM-AAAA (chaîne 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()}`
}
// ── Confirmation d'intégration ───────────────────────────────────────────────
const confirmOpen = ref(false)