An event countdown card
Build a card for the Hectal JS Meetup, which starts at 2024-02-10T12:30:00Z. To keep the result testable, "now" is fixed at 2024-01-15T10:30:00Z.
1. daysUntil(now, target) takes two Dates and returns how many calendar days (in UTC) are between their dates, ignoring the time of day: from 15 Jan 10:30 to 16 Jan 01:00 is 1 day.
2. countdownText(days) returns Today! for 0, 1 day to go for 1, 26 days to go for 26 (any number above 1), and Event over for negative numbers.
3. Show the event's date and time in #when, formatted for India (en-IN) in the Asia/Kolkata time zone, with the weekday, day, month name and year and the time. Put countdownText(...) in #countdown.
What Check tests
daysUntilgives 26 from 15 Jan to 10 Feb 2024daysUntilcounts calendar days, not 24-hour blockscountdownTexthandles today, one day, many days and the past- The card shows
26 days to go - The date is shown in India time with the weekday and month name
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Your page
Console
Nothing logged yet.