{
  "id": "days-until-fourth-of-july",
  "version": "7d9cc902fb02",
  "status": "published",
  "name": "Days Until The Fourth of July",
  "question": "Days until July 4th",
  "summary": "Counts the days from today, or any date you choose, to the next Fourth of July, with its date and day of the week.",
  "category": "days",
  "subcategory": "countdowns",
  "url": "https://www.acalculator.org/days/days-until-fourth-of-july",
  "markdown": "https://www.acalculator.org/days/days-until-fourth-of-july.md",
  "kind": "function",
  "method": "Find the first date of the Fourth of July on or after the start date, then count the days from the start date to it.",
  "assumptions": [
    "Independence Day (the Fourth of July) is July 4 every year.",
    "Start dates from January 1, 1986 to December 31, 2400 work, because the US federal holiday rules used here start in 1986.",
    "The start date itself is not counted: from the day before, the count is 1; on the day itself, it is 0.",
    "Dates are calendar days with no time of day, so a time zone or a daylight-saving change never adds or loses a day.",
    "When the date falls on a weekend, the US federal day off moves to the Friday before or the Monday after; the count is to the date itself."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "from": {
        "title": "Count from",
        "description": "The date to count from. Today, unless you change it.",
        "type": "string",
        "format": "date"
      }
    }
  },
  "outputs": {
    "days": {
      "label": "Days until the Fourth of July",
      "description": "Whole days from the start date to the next Fourth of July; 0 on the day itself.",
      "format": "integer"
    },
    "date": {
      "label": "Date",
      "description": "The next date of the Fourth of July on or after the start date.",
      "format": "date-long"
    },
    "weekday": {
      "label": "Day of the week",
      "description": "The weekday of that date.",
      "format": "text"
    },
    "weeks": {
      "label": "In weeks",
      "description": "The same number of days in weeks and days.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "from": "2026-09-29"
    },
    "outputs": {
      "days": 278,
      "date": "2027-07-04",
      "weekday": "Sunday",
      "weeks": "39 weeks and 5 days"
    },
    "text": "From September 29, 2026, there are 278 days until the Fourth of July on Sunday, July 4, 2027."
  },
  "examples": [
    {
      "given": {
        "from": "2026-01-01"
      },
      "expect": {
        "date": "2026-07-04",
        "days": 184
      },
      "source": "5 U.S.C. 6103 (federal holidays), with OPM federal holiday schedules"
    },
    {
      "given": {
        "from": "2026-07-05"
      },
      "expect": {
        "date": "2027-07-04",
        "days": 364
      },
      "source": "5 U.S.C. 6103 (federal holidays), with OPM federal holiday schedules"
    }
  ],
  "sources": [
    "5 U.S.C. 6103 (federal holidays), with OPM federal holiday schedules"
  ],
  "related": [
    "days-until-labor-day",
    "days-until-fall",
    "days-until-halloween",
    "days-until-election-day",
    "days-until-veterans-day",
    "days-between-dates"
  ],
  "changelog": []
}
