# HG changeset patch # User drewp@bigasterisk.com # Date 1725756456 25200 # Node ID a90cb6927c7d461364f0393e7e9cb37c09abf2c5 # Parent e8c90d8939194a87983094ed44ecb49f600cb0ac fix countdown queries. Display "now" instead of "In -0.4 hours" diff -r e8c90d893919 -r a90cb6927c7d src/DisplayEvent.ts --- a/src/DisplayEvent.ts Mon Aug 26 16:17:49 2024 -0700 +++ b/src/DisplayEvent.ts Sat Sep 07 17:47:36 2024 -0700 @@ -12,9 +12,14 @@ return getLiteral(this.store, this.graph, this.uri, namedNode(EV + "title"), "(unnamed)"); } get start(): string { - return getLiteral(this.store, this.graph, this.uri, namedNode(EV + "start"), null); + var ret = getLiteral(this.store, this.graph, this.uri, namedNode(EV + "start"), null); + if (ret == null || ret === "") { + ret = getLiteral(this.store, this.graph, this.uri, namedNode(EV + "startDate"), null); + } + return ret; } - get feed(): NamedNode { + get calendar(): NamedNode { + // todo: broken- it's now (calendar, :event, event) return namedNode(getLiteral(this.store, this.graph, this.uri, namedNode(EV + "feed"), null)); } shortDate(): TemplateResult { @@ -22,13 +27,16 @@ return html`${format(t, "EEE, MMM d,")} ${format(t, "HH:mm")}`; } inHowLong(): TemplateResult { - // returns start()-now, like '5 days' + // returns start()-now, like 'In 5 days' const t = parseISO(this.start).valueOf(); const now = Date.now(); const daysAway = (t - now) / 1000 / 86400; + if (daysAway < 0) { + return html`NOW`; + } const prec = daysAway < 2 ? 1 : 0; const cls = "until " + (daysAway < 2 ? "until-2d" : daysAway < 7 ? "until-7d" : daysAway < 30 ? "until-1mo" : ""); - return html`${daysAway.toFixed(prec)} days`; + return html`In ${daysAway.toFixed(prec)} days`; } show(): boolean { const now = new Date(); @@ -40,6 +48,6 @@ end = endOfTomorrow(); } - return isWithinInterval(t, { start, end }) && !hideTitles.has(this.title) && !hideFeeds.has(this.feed.value); + return isWithinInterval(t, { start, end }) && !hideTitles.has(this.title) && !hideFeeds.has(this.calendar.value); } } diff -r e8c90d893919 -r a90cb6927c7d src/FdCountdown.ts --- a/src/FdCountdown.ts Mon Aug 26 16:17:49 2024 -0700 +++ b/src/FdCountdown.ts Sat Sep 07 17:47:36 2024 -0700 @@ -74,7 +74,7 @@ render() { return html`

Coming Soon

    - ${this.evs.map((d) => html`
  1. In ${d.inHowLong()}, ${d.title}
  2. `)} + ${this.evs.map((d) => html`
  3. ${d.inHowLong()}, ${d.title}
  4. `)}
`; } } diff -r e8c90d893919 -r a90cb6927c7d src/parseRdf.ts --- a/src/parseRdf.ts Mon Aug 26 16:17:49 2024 -0700 +++ b/src/parseRdf.ts Sat Sep 07 17:47:36 2024 -0700 @@ -7,7 +7,7 @@ store.getObjects(subj, pred, graph).forEach((attr) => { out = attr.value; }); - if (!out) { + if (out == null) { if (missing === null) { throw new Error(); }