feat: build Onyx SSR shell and plan hero with mock data
This commit is contained in:
1 parent
84c20992f9
commit
2db494fb10
34 files changed
+3197
-2
No files matched your search
@@ -0,0 +1,99 @@
|
||||
import { BERLIN_TZ } from '#shared/staffing'
|
||||
|
||||
const dateFormatter = new Intl.DateTimeFormat('en-GB', {
|
||||
timeZone: BERLIN_TZ,
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
year: 'numeric',
|
||||
})
|
||||
|
||||
const shortDateFormatter = new Intl.DateTimeFormat('en-GB', {
|
||||
timeZone: BERLIN_TZ,
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
})
|
||||
|
||||
const weekdayFormatter = new Intl.DateTimeFormat('en-GB', {
|
||||
timeZone: BERLIN_TZ,
|
||||
weekday: 'long',
|
||||
})
|
||||
|
||||
const weekdayShortFormatter = new Intl.DateTimeFormat('en-GB', {
|
||||
timeZone: BERLIN_TZ,
|
||||
weekday: 'short',
|
||||
})
|
||||
|
||||
const dateTimeFormatter = new Intl.DateTimeFormat('en-GB', {
|
||||
timeZone: BERLIN_TZ,
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hourCycle: 'h23',
|
||||
})
|
||||
|
||||
const timeFormatter = new Intl.DateTimeFormat('en-GB', {
|
||||
timeZone: BERLIN_TZ,
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hourCycle: 'h23',
|
||||
})
|
||||
|
||||
const euroFormatter = new Intl.NumberFormat('en-GB', {
|
||||
style: 'currency',
|
||||
currency: 'EUR',
|
||||
maximumFractionDigits: 0,
|
||||
})
|
||||
|
||||
const numberFormatter = new Intl.NumberFormat('en-GB')
|
||||
|
||||
/** Date-only strings are parsed at noon UTC so the local date never shifts. */
|
||||
function toDate(value: string): Date {
|
||||
return value.length > 10 ? new Date(value) : new Date(`${value}T12:00:00Z`)
|
||||
}
|
||||
|
||||
function formatWith(formatter: Intl.DateTimeFormat, value: string): string {
|
||||
const date = toDate(value)
|
||||
return Number.isNaN(date.getTime()) ? '—' : formatter.format(date)
|
||||
}
|
||||
|
||||
export function formatDate(date: string): string {
|
||||
return formatWith(dateFormatter, date)
|
||||
}
|
||||
|
||||
export function formatShortDate(date: string): string {
|
||||
return formatWith(shortDateFormatter, date)
|
||||
}
|
||||
|
||||
export function formatWeekday(date: string): string {
|
||||
return formatWith(weekdayFormatter, date)
|
||||
}
|
||||
|
||||
export function formatWeekdayShort(date: string): string {
|
||||
return formatWith(weekdayShortFormatter, date)
|
||||
}
|
||||
|
||||
/** Format a wire timestamp in Heilbronn local time. */
|
||||
export function formatDateTime(iso: string): string {
|
||||
return formatWith(dateTimeFormatter, iso)
|
||||
}
|
||||
|
||||
export function formatTime(iso: string): string {
|
||||
return formatWith(timeFormatter, iso)
|
||||
}
|
||||
|
||||
export function formatEuro(value: number): string {
|
||||
return euroFormatter.format(value)
|
||||
}
|
||||
|
||||
export function formatNumber(value: number): string {
|
||||
return numberFormatter.format(value)
|
||||
}
|
||||
|
||||
export function formatPercent(value: number, digits = 0): string {
|
||||
return `${value.toFixed(digits)}%`
|
||||
}
|
||||
|
||||
export function weekLabel(start: string, end: string): string {
|
||||
return `${formatShortDate(start)} – ${formatDate(end)}`
|
||||
}
|
||||
Reference in new issue
Block a user