mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-20 05:56:53 +00:00
a4e3e83d3f
The transport detail dialog and the phone transport sheet name the booking's day and each segment's own booking code through transportDetailModel, next to the files filter they already share. The rest of the two views reads the booking differently on purpose and stays as it is.
26 lines
993 B
TypeScript
26 lines
993 B
TypeScript
type Translate = (key: string, params?: Record<string, string | number>) => string;
|
|
|
|
/**
|
|
* What the desktop transport detail dialog and the phone transport sheet both read
|
|
* off a booking. The booking's files come from utils/reservationFiles.
|
|
*/
|
|
|
|
/** The day a booking runs on, as the head of either detail names it, in the locale's order ("Wed, Jul 1" in en-US). */
|
|
export function bookingDayLabel(date: string, locale: string): string {
|
|
return new Date(`${date}T00:00:00Z`).toLocaleDateString(locale, {
|
|
weekday: 'short',
|
|
day: 'numeric',
|
|
month: 'short',
|
|
timeZone: 'UTC',
|
|
});
|
|
}
|
|
|
|
/**
|
|
* The name a segment's own booking code is listed under (#1943): where it leaves
|
|
* from and where it goes, or the plain booking code label when the segment names
|
|
* neither.
|
|
*/
|
|
export function segmentCodeLabel(leg: { from?: string | null; to?: string | null }, t: Translate): string {
|
|
return [leg.from, leg.to].filter(Boolean).join(' → ') || t('reservations.confirmationCode');
|
|
}
|