Drop very-early-morning slots from the +1/+2 day 3-hourly cards
Was showing every 3-hourly point the provider returns (8/day, including ~1am/~4am). Now filters to hour >= 6 London-local for both providers, leaving 6 daytime-through-evening slots per day — currently 7/10/13/16/ 19/22 on Met Office's BST-aligned feed. Threshold rather than a hardcoded hour set so it keeps working once the clocks change to GMT and Met Office's fixed UTC cadence shifts by an hour locally. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
d094e78885
commit
d069f1147a
1 changed files with 10 additions and 2 deletions
|
|
@ -42,6 +42,14 @@ function londonDateKey(isoTime) {
|
||||||
function londonHour(isoTime) {
|
function londonHour(isoTime) {
|
||||||
return parseInt(new Date(isoTime).toLocaleString('en-GB', { timeZone: 'Europe/London', hour: '2-digit', hour12: false }))
|
return parseInt(new Date(isoTime).toLocaleString('en-GB', { timeZone: 'Europe/London', hour: '2-digit', hour12: false }))
|
||||||
}
|
}
|
||||||
|
// The 3-hourly tier (tomorrow/day-after "Coming up" cards) drops the very early
|
||||||
|
// morning slots nobody's checking the display for. A threshold rather than an
|
||||||
|
// exact hour set — Met Office's feed is a fixed UTC-aligned 3-hour cadence, so
|
||||||
|
// its London-local hours shift by 1 across the BST/GMT change (right now, BST,
|
||||||
|
// that's 1/4/7/10/13/16/19/22; in winter it's 0/3/6/9/12/15/18/21). ">= 6" drops
|
||||||
|
// the same two earliest slots either way instead of matching zero points once
|
||||||
|
// the clocks change.
|
||||||
|
const THREE_HOURLY_MIN_HOUR = 6
|
||||||
// Pure date math, not derived from any provider response — "tomorrow"/"day after"
|
// Pure date math, not derived from any provider response — "tomorrow"/"day after"
|
||||||
// are always just today+1/+2 regardless of source, which is what lets each tier
|
// are always just today+1/+2 regardless of source, which is what lets each tier
|
||||||
// below be fetched (and fall back) fully independently of the others.
|
// below be fetched (and fall back) fully independently of the others.
|
||||||
|
|
@ -100,7 +108,7 @@ async function fetchMetOfficeHourly(lat, lon, apiKey) {
|
||||||
|
|
||||||
async function fetchMetOfficeThreeHourly(lat, lon, apiKey, dayKeys) {
|
async function fetchMetOfficeThreeHourly(lat, lon, apiKey, dayKeys) {
|
||||||
const series = await fetchMetOfficeTimestep('three-hourly', lat, lon, apiKey)
|
const series = await fetchMetOfficeTimestep('three-hourly', lat, lon, apiKey)
|
||||||
const dayRows = series.filter(p => dayKeys.includes(londonDateKey(p.time)))
|
const dayRows = series.filter(p => dayKeys.includes(londonDateKey(p.time)) && londonHour(p.time) >= THREE_HOURLY_MIN_HOUR)
|
||||||
const points = dayRows
|
const points = dayRows
|
||||||
.map(p => ({
|
.map(p => ({
|
||||||
resolution: '3hourly',
|
resolution: '3hourly',
|
||||||
|
|
@ -208,7 +216,7 @@ function openMeteoHourlyPoints(hourlyRows) {
|
||||||
}
|
}
|
||||||
function openMeteoThreeHourlyPoints(hourlyRows, dayKeys) {
|
function openMeteoThreeHourlyPoints(hourlyRows, dayKeys) {
|
||||||
return hourlyRows
|
return hourlyRows
|
||||||
.filter(r => dayKeys.includes(r.dateKey) && r.hour % 3 === 0)
|
.filter(r => dayKeys.includes(r.dateKey) && r.hour % 3 === 0 && r.hour >= THREE_HOURLY_MIN_HOUR)
|
||||||
.map(r => ({
|
.map(r => ({
|
||||||
resolution: '3hourly',
|
resolution: '3hourly',
|
||||||
ts: r.time,
|
ts: r.time,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue