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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user