1import { d as formatRelative, l as parse, m as enUS, p as format, r as TZDate } from "./vendor-date-d6_4rWHy.js"; 2var tokens = { 3 today: "'Today' HH:mm'", 4 yesterday: "'Yesterday' HH:mm'", 5 tomorrow: "'Tomorrow at' p", 6 lastWeek: "'Last' eeee 'at' p", 7 nextWeek: "eeee 'at' p", 8 other: "MMM d, yyyy, HH:mm" 9}; 10const TIMEZONE_ABBR_TO_IANA = { 11 EST: "America/New_York", 12 EDT: "America/New_York", 13 CST: "America/Chicago", 14 CDT: "America/Chicago", 15 MST: "America/Denver", 16 MDT: "America/Denver", 17 PST: "America/Los_Angeles", 18 PDT: "America/Los_Angeles", 19 AKST: "America/Anchorage", 20 AKDT: "America/Anchorage", 21 HST: "Pacific/Honolulu" 22}; 23var formatRelativeFn = (token, _date, _baseDate, _options) => tokens[token]; 24const locale = { 25 ...enUS, 26 formatRelative: formatRelativeFn 27}; 28var tokensWithoutTime = { 29 today: "'Today'", 30 yesterday: "'Yesterday'", 31 tomorrow: "'Tomorrow'", 32 lastWeek: "MMM d", 33 nextWeek: "eeee", 34 other: "MMM d, yyyy" 35}; 36var formatRelativeWithoutTimeFn = (token, _date, _baseDate, _options) => tokensWithoutTime[token]; 37var localeWithoutTime = { 38 ...enUS, 39 formatRelative: formatRelativeWithoutTimeFn 40}; 41var _formatRelative = (date, baseDate, options) => formatRelative(date, baseDate, { 42 ...options, 43 locale 44}); 45var _formatRelativeDay = (date, baseDate, options) => formatRelative(date, baseDate, { 46 ...options, 47 locale: localeWithoutTime 48}); 49var formatMinutesSeconds = (milliseconds) => { 50 const totalSeconds = Math.floor(milliseconds / 1e3); 51 const minutes = Math.floor(totalSeconds / 60); 52 const secondsRemainder = totalSeconds % 60; 53 return `${minutes.toString().padStart(2, "0")}:${secondsRemainder.toString().padStart(2, "0")}`; 54}; 55function getCurrentTimeZone() { 56 try { 57 return new Intl.DateTimeFormat("en-US", { timeZoneName: "long" }).format(/* @__PURE__ */ new Date()).split(",")[1].split(" ").map((x) => x[0]).filter((x) => x).join(""); 58 } catch (error) { 59 console.error(error); 60 return ""; 61 } 62} 63var CALCULATE_DATE_FORMMAT = "yyyy-MM-dd HH:mm:ss"; 64var CALCULATE_DATE_ONLY_FORMMAT = "yyyy-MM-dd"; 65var BROWSER_TIMEZONE = Intl.DateTimeFormat().resolvedOptions().timeZone; 66var safeFormatDate = (value, formatStr = "MMM d, yyyy", fallback = "--", options = { locale }) => { 67 if (value === null || value === void 0 || value === "") return fallback; 68 const date = value instanceof Date ? value : new Date(value); 69 if (Number.isNaN(date.getTime())) return fallback; 70 return format(date, formatStr, options); 71}; 72function detectTimeZoneType(tz) { 73 if (!tz) return "invalid"; 74 if (tz.includes("/")) return "iana"; 75 if (/^(GMT|UTC)[+-]\d{1,2}$/.test(tz)) return "offset"; 76 if (/^[A-Z]{2,5}$/.test(tz)) return "abbreviation"; 77 return "unknown"; 78} 79function getShortTimeZone(timeZone) { 80 return new Intl.DateTimeFormat("en-US", { 81 timeZone, 82 timeZoneName: "short" 83 }).formatToParts(/* @__PURE__ */ new Date()).find((p) => p.type === "timeZoneName")?.value; 84} 85function normalizeTimeZone(input) { 86 if (!input) return { 87 iana: "UTC", 88 abbr: "UTC" 89 }; 90 const tz = input.trim(); 91 const upper = tz.toUpperCase(); 92 if (TIMEZONE_ABBR_TO_IANA[upper]) return { 93 iana: TIMEZONE_ABBR_TO_IANA[upper], 94 abbr: upper 95 }; 96 if (tz.includes("/")) { 97 const abbr = getShortTimeZone(tz) ?? tz; 98 return { 99 iana: tz, 100 abbr 101 }; 102 } 103 return { 104 iana: "UTC", 105 abbr: "UTC" 106 }; 107} 108const formatDateWithTimezone = (timestamp, dateFormat = "MMM d, yyyy, HH:mm", timezone) => { 109 if (!timestamp) return "N/A"; 110 const isIana = detectTimeZoneType(timezone ?? void 0) == "iana"; 111 const normalized = (isIana ? getShortTimeZone(timezone) : timezone) ? normalizeTimeZone(timezone ?? void 0) : null; 112 if (!isIana && !normalized) return safeFormatDate(timestamp, dateFormat); 113 const date = new TZDate(timestamp, normalized.iana); 114 return safeFormatDate(date, dateFormat) + (normalized ? ` ${normalized.abbr}` : ""); 115}; 116function parseDepartureTimeToUnix(timeString, tz) { 117 if (!timeString) return; 118 const numeric = Number(timeString); 119 if (!isNaN(numeric) && numeric > 1e9) return numeric; 120 const d = parse(timeString, CALCULATE_DATE_FORMMAT, /* @__PURE__ */ new Date()); 121 return Math.floor(TZDate.tz(normalizeTimeZone(tz).iana, d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds()).getTime() / 1e3); 122} 123export { _formatRelative as a, formatMinutesSeconds as c, parseDepartureTimeToUnix as d, safeFormatDate as f, TIMEZONE_ABBR_TO_IANA as i, getCurrentTimeZone as l, CALCULATE_DATE_FORMMAT as n, _formatRelativeDay as o, CALCULATE_DATE_ONLY_FORMMAT as r, formatDateWithTimezone as s, BROWSER_TIMEZONE as t, locale as u };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.