Skip to content

Commit

Permalink
fix: logic for Before Start condition
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisburnell committed Apr 12, 2024
1 parent 1636070 commit dd5f427
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions event-countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,13 @@ class EventCountdown extends HTMLElement {
if (this.start && this.end && this.start.getTime() < nowEpoch && nowEpoch < this.end.getTime()) {
// Between start and end
return `${this.name}${this.startPast}<time datetime="${this.start.toISOString()}" title="${this.start.toLocaleString()}">${this.getRelativeTime(this.start, this.division)}</time>${(this.conjunction + this.endFuture).replace(/ +/g, " ")}<time datetime="${this.end.toISOString()}" title="${this.end.toLocaleString()}">${this.getRelativeTime(this.end, this.division)}</time>.`
} else if (this.start && nowEpoch < this.start.getTime()) {
// Before start
return `${this.name}${this.startFuture}<time datetime="${this.start.toISOString()}" title="${this.start.toLocaleString()}">${this.getRelativeTime(this.start, this.division)}</time>.`
} else if (this.start && !this.end) {
if (nowEpoch < this.start.getTime()) {
// Before start
return `${this.name}${this.startFuture}<time datetime="${this.start.toISOString()}" title="${this.start.toLocaleString()}">${this.getRelativeTime(this.start, this.division)}</time>.`
}
// After start
return `${this.name}${this.startPast}<time datetime="${this.start.toISOString()}" title="${this.start.toLocaleString()}">${this.getRelativeTime(this.start, this.division)}</time>.`
}
if (nowEpoch < this.end.getTime()) {
} else if (nowEpoch < this.end.getTime()) {
// Before end
return `${this.name}${this.endFuture}<time datetime="${this.end.toISOString()}" title="${this.end.toLocaleString()}">${this.getRelativeTime(this.end, this.division)}</time>.`
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chrisburnell/event-countdown",
"version": "0.0.5",
"version": "0.0.6",
"description": "A Web Component to display an event countdown.",
"author": "Chris Burnell <me@chrisburnell.com>",
"contributors": [
Expand Down

0 comments on commit dd5f427

Please sign in to comment.