Compare commits
2 Commits
v3.0.0-dev
...
v3.0.0-dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 59e8a77d3d | |||
| 1f1e215c0c |
@@ -46,6 +46,7 @@
|
||||
background: transparent;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
margin-bottom: 0;
|
||||
width: 95%;
|
||||
max-width: 750px;
|
||||
}
|
||||
@@ -112,7 +113,7 @@
|
||||
filter: brightness(1.2);
|
||||
color: var(--color-title);
|
||||
font-family: 'URW Gothic', sans-serif;
|
||||
font-size: 1.0rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
z-index: 1;
|
||||
|
||||
@@ -3,13 +3,16 @@ import type { ApiTrainsTrainDetails } from '@owlboard/owlboard-ts';
|
||||
* Converts ISO/JSON time to UK-formatted HH:MM string, with optional (default off) seconds
|
||||
* Ensures Europe/London timezone irrespective of browser timezone.
|
||||
*/
|
||||
export function formatUkTime(dateStr: string | Date | undefined, includeSeconds: boolean = false): string {
|
||||
export function formatUkTime(
|
||||
dateStr: string | Date | undefined,
|
||||
includeSeconds: boolean = false
|
||||
): string {
|
||||
if (!dateStr) return '--:--';
|
||||
const date = typeof dateStr === 'string' ? new Date(dateStr) : dateStr;
|
||||
|
||||
if (isNaN(date.getTime())) return '--:--';
|
||||
|
||||
return date.toLocaleTimeString('en-GB', {
|
||||
return date.toLocaleTimeString('en-GB', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
...(includeSeconds && { second: '2-digit' }),
|
||||
@@ -22,14 +25,18 @@ return date.toLocaleTimeString('en-GB', {
|
||||
* Converts ISO/JSON time to UK-formatted DD/MM/YY HH:MM:SS string.
|
||||
* Ensures Europe/London timezone irrespective of browser timezone.
|
||||
*/
|
||||
export function formatUkDateTime(dateStr: string | Date | undefined, includeSeconds: boolean = false): string {
|
||||
export function formatUkDateTime(
|
||||
dateStr: string | Date | undefined,
|
||||
includeSeconds: boolean = false
|
||||
): string {
|
||||
if (!dateStr) return '--/--/-- --:--:--';
|
||||
|
||||
const date = typeof dateStr === 'string' ? new Date(dateStr) : dateStr;
|
||||
|
||||
if (isNaN(date.getTime())) return '--/--/-- --:--:--';
|
||||
|
||||
return date.toLocaleString('en-GB', {
|
||||
return date
|
||||
.toLocaleString('en-GB', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: '2-digit',
|
||||
@@ -38,7 +45,8 @@ export function formatUkDateTime(dateStr: string | Date | undefined, includeSeco
|
||||
...(includeSeconds && { second: '2-digit' }),
|
||||
hour12: false,
|
||||
timeZone: 'Europe/London'
|
||||
}).replace(',', '');
|
||||
})
|
||||
.replace(',', '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
}, 1000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
})
|
||||
});
|
||||
|
||||
// Update 'QuickLinks'
|
||||
$effect(() => {
|
||||
@@ -33,70 +33,66 @@
|
||||
// Load Data Invalidation Handling
|
||||
// Refresh countdown logic
|
||||
</script>
|
||||
<section class="board-wrapper">
|
||||
{#if data.boardData.data.m?.length}
|
||||
|
||||
<section class="board-wrapper">
|
||||
{#if data.boardData.data.m?.length}
|
||||
<StationAlertCard messages={data.boardData.data.m} />
|
||||
{/if}
|
||||
<div class="time-data">
|
||||
<span class="time-loaded">Fetched: {formatUkDateTime(data.boardData.producedAt, true)}</span>
|
||||
<span class="time-loaded">Updated: {formatUkDateTime(data.boardData.producedAt, true)}</span>
|
||||
<span class="time-now">{formatUkTime(now, true)}</span>
|
||||
</div>
|
||||
|
||||
{/if}
|
||||
<pre class="json-dump">{JSON.stringify(data.boardData.data.s, null, 2)}</pre>
|
||||
</section>
|
||||
|
||||
<section class="section-t">Live boards are not yet fully implemented on the server</section>
|
||||
|
||||
<pre class="json-dump">{JSON.stringify(data.boardData.data.s, null, 2)}</pre>
|
||||
|
||||
<style>
|
||||
.board-wrapper {
|
||||
.board-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
gap: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.time-data {
|
||||
.time-data {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
margin: 0 auto;
|
||||
margin: 10px auto;
|
||||
font-family: 'URW Gothic', sans-serif;
|
||||
}
|
||||
|
||||
.time-loaded, .time-now {
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.time-loaded {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.time-now {
|
||||
font-weight: 600;
|
||||
font-size: 1rem;
|
||||
}
|
||||
.section-t {
|
||||
font-family: 'URW Gothic', sans-serif;
|
||||
text-align: center;
|
||||
font-size: 2rem;
|
||||
width: 90%;
|
||||
margin: auto;
|
||||
padding-top: 25px;
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
.time-loaded,
|
||||
.time-now {
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.time-loaded {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.time-now {
|
||||
font-weight: 600;
|
||||
font-size: 1rem;
|
||||
}
|
||||
pre {
|
||||
max-width: 100%;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
box-sizing: border-box;
|
||||
overflow-x: auto;
|
||||
}
|
||||
.json-dump {
|
||||
background: #222;
|
||||
color: #0f0;
|
||||
padding: 1rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9rem;
|
||||
max-height: 500px;
|
||||
width: 95%;
|
||||
margin: 1rem auto; }
|
||||
margin: 1rem auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user