How many days to Christmas?

Calculate the number of days to wait before Christmas is here.

Face with waiting expression Nothing to see yet!

Loading takeymakey...
TakeyMakey code
Want this tool to do something else? Edit the code below and make it do whatever you want.
({
  take: [
    { key: "y", type: "number", label: "Year", value: 2022 },
    { key: "m", type: "number", label: "Month", value: 12, min: 1, max: 12 },
    { key: "d", type: "number", label: "Day", value: 25, min: 1, max: 31 },
  ],
  make: ({ y, m, d }) => {
    const d0 = new Date()
    const d1 = new Date().setFullYear(y, m - 1, d)

    const dayMs = 1000 * 60 * 60 * 24
    const delta = Math.abs(Math.round((d1 - d0) / dayMs))

    const lang = "default"
    const days = new Intl.NumberFormat(lang).format(delta)

    const date = new Intl.DateTimeFormat(lang, {
      year: "numeric",
      day: "numeric",
      month: "long",
      weekday: "long",
      era: y < 1200 ? "short" : undefined,
    }).format(d1)

    const isOrAre = delta === 1 ? "is" : "are"
    const dayOrDays = delta === 1 ? "day" : "days"

    let title, body

    if (d1 - d0 === 0) {
      title = `It's here!`
      body = `It's ${date} today!`
    } else if (d1 - d0 > 0) {
      title = `${days} ${dayOrDays} left`
      body = `There ${isOrAre} ${days} ${dayOrDays} to go until ${date}!`
    } else {
      title = `${days} ${dayOrDays} ago`
      body = `It's been ${days} ${dayOrDays} since ${date}!`
    }

    return {
      type: "card",
      title,
      body,
    }
  },
})