UNPKG

@goteborgco/open-api-js-client

Version:

Official JavaScript client for the Göteborg & Co GraphQL API

35 lines (34 loc) 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EventDate = void 0; class EventDate { constructor(data) { this.start = data.start; this.end = data.end; } /** * Check if the date range is currently active * @returns boolean indicating if the current date is within the range */ isActive() { const now = new Date(); const start = this.start ? new Date(this.start) : null; const end = this.end ? new Date(this.end) : null; return (!start || start <= now) && (!end || end >= now); } /** * Get formatted date range string * @returns Formatted date range or undefined if no dates exist */ getFormattedRange() { if (!this.start && !this.end) return undefined; const start = this.start ? new Date(this.start).toLocaleDateString() : undefined; const end = this.end ? new Date(this.end).toLocaleDateString() : undefined; if (start && end) { return `${start} - ${end}`; } return start || end; } } exports.EventDate = EventDate;