Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion html_js/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ let latestOdorData = null;
let latestBeachData = null;

// --- Date/Time Formatting Helpers ---
// H2S timestamps are always in PST. When DST is active (PDT), add 1 hour.
function adjustPSTTimestamp(dayjsObj) {
const jan = new Date(dayjsObj.year(), 0, 1).getTimezoneOffset();
const now = new Date().getTimezoneOffset();
const isDST = now < jan;
return isDST ? dayjsObj.add(1, "hour") : dayjsObj;
}
function formatDateTime(date, options) {
// Use i18next's detected language for formatting
const lang = i18next.language || "en"; // Fallback to 'en'
Expand Down Expand Up @@ -66,7 +73,7 @@ function renderH2STable(jsonData) {
const clockIcon = document.createElement("i");
clockIcon.className = "bi bi-clock";
const dateElm = document.createElement("span");
let dateWithTime = dayjs(h2s["Date with time"]).toDate(); // Convert to JS Date for Intl
let dateWithTime = adjustPSTTimestamp(dayjs(h2s["Date with time"])).toDate(); // Convert to JS Date for Intl
// Format using Intl based on example 'ddd h A'
const timeString = formatDateTime(dateWithTime, {
weekday: "short",
Expand Down
2 changes: 1 addition & 1 deletion html_js/js/mbmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ function h2s_layer() {
} else {
var name = feature.properties["SiteName"].replace(/\([A-Z]+\)/g, "");
}
let date = dayjs(feature.properties["Date with time"]);
let date = adjustPSTTimestamp(dayjs(feature.properties["Date with time"]));
var airnow_link = `https://www.airnow.gov/?city=${feature.properties["Site Name"]}&state=CA&country=USA`;

var result = feature.properties.Result;
Expand Down
3 changes: 3 additions & 0 deletions html_js/notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ https://stackoverflow.com/questions/69086721/how-to-render-custom-svg-in-iconlay


county link

== note the h2s data is in PST, so when in PDT add an hour.