{
  "id": "time-to-decimal",
  "version": "887b9a7ffdd6",
  "status": "published",
  "name": "Time to Decimal Calculator",
  "question": "How to convert time to decimal?",
  "summary": "Converts hours, minutes, and seconds to decimal hours (7:45 is 7.75 hours), and decimal hours back to hours, minutes, and seconds.",
  "category": "days",
  "subcategory": "time-and-hours",
  "url": "https://www.acalculator.org/days/time-to-decimal-calculator",
  "markdown": "https://www.acalculator.org/days/time-to-decimal-calculator.md",
  "kind": "function",
  "method": "decimal hours = hours + minutes ÷ 60 + seconds ÷ 3,600; back: seconds = decimal hours × 3,600, split into hours, minutes, and seconds",
  "assumptions": [
    "An hour is 60 minutes and a minute is 60 seconds.",
    "Converting a time, the hours, minutes, and seconds are whole numbers; minutes and seconds may be 60 or more.",
    "Converting decimal hours, the time is rounded half up to the nearest millisecond."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "mode": {
        "title": "Convert",
        "description": "Convert a time to decimal hours, or decimal hours to a time.",
        "type": "string",
        "enum": [
          "toDecimal",
          "toTime"
        ]
      },
      "h": {
        "title": "Hours",
        "description": "Whole hours of the time.",
        "type": "integer",
        "minimum": 0,
        "maximum": 100000
      },
      "m": {
        "title": "Minutes",
        "description": "Whole minutes of the time. 60 or more is fine.",
        "type": "integer",
        "minimum": 0,
        "maximum": 1000000
      },
      "s": {
        "title": "Seconds",
        "description": "Whole seconds of the time. 60 or more is fine.",
        "type": "integer",
        "minimum": 0,
        "maximum": 10000000
      },
      "dec": {
        "title": "Decimal hours",
        "description": "A time in hours with a decimal point, such as 7.75.",
        "type": "number",
        "minimum": 0,
        "maximum": 100000
      }
    }
  },
  "outputs": {
    "time": {
      "label": "Time",
      "description": "Converting decimal hours: the time in whole hours, whole minutes, and seconds.",
      "format": "duration"
    },
    "hours": {
      "label": "Decimal hours",
      "description": "The time in hours: hours + minutes ÷ 60 + seconds ÷ 3,600.",
      "format": "number"
    },
    "clock": {
      "label": "As h:mm:ss",
      "description": "The time written as hours:minutes:seconds, with minutes and seconds under 60.",
      "format": "text"
    },
    "minutes": {
      "label": "Decimal minutes",
      "description": "The time in minutes: hours × 60 + minutes + seconds ÷ 60.",
      "format": "number"
    },
    "seconds": {
      "label": "Seconds",
      "description": "The time in seconds: hours × 3,600 + minutes × 60 + seconds.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "mode": "toDecimal",
      "h": 7,
      "m": 45,
      "s": 0,
      "dec": 7.75
    },
    "outputs": {
      "hours": 7.75,
      "clock": "7:45:00",
      "minutes": 465,
      "seconds": 27900
    },
    "text": "7:45:00 is 7.75 hours."
  },
  "examples": [
    {
      "given": {
        "mode": "toDecimal",
        "h": 7,
        "m": 45,
        "s": 0
      },
      "expect": {
        "hours": 7.75,
        "clock": "7:45:00",
        "minutes": 465,
        "seconds": 27900
      },
      "source": "SI Brochure (BIPM, 9th edition, 2019), Table 8: 1 h = 60 min = 3,600 s; hand calculation in content.mdx: 7 + 45 ÷ 60 = 7.75"
    },
    {
      "given": {
        "mode": "toDecimal",
        "h": 1,
        "m": 20,
        "s": 15
      },
      "expect": {
        "hours": 1.3375,
        "clock": "1:20:15",
        "minutes": 80.25,
        "seconds": 4815
      },
      "source": "SI Brochure (BIPM, 9th edition, 2019), Table 8; hand calculation in content.mdx: 4,815 ÷ 3,600 = 1.3375"
    },
    {
      "given": {
        "mode": "toDecimal",
        "h": 0,
        "m": 90,
        "s": 0
      },
      "expect": {
        "hours": 1.5,
        "clock": "1:30:00"
      },
      "source": "hand calculation in content.mdx: 90 ÷ 60 = 1.5"
    },
    {
      "given": {
        "mode": "toTime",
        "dec": 1.2345
      },
      "expect": {
        "time": {
          "hours": 1,
          "minutes": 14,
          "seconds": 4.2
        },
        "clock": "1:14:04.2",
        "minutes": 74.07,
        "seconds": 4444.2
      },
      "source": "SI Brochure (BIPM, 9th edition, 2019), Table 8; hand calculation in content.mdx: 1.2345 × 3,600 = 4,444.2 s"
    },
    {
      "given": {
        "mode": "toTime",
        "dec": 0.3
      },
      "expect": {
        "time": {
          "hours": 0,
          "minutes": 18,
          "seconds": 0
        },
        "clock": "0:18:00",
        "seconds": 1080
      },
      "source": "hand calculation in content.mdx: 0.3 × 60 = 18 minutes"
    }
  ],
  "sources": [
    "Bureau International des Poids et Mesures, The International System of Units (SI Brochure, 9th edition, 2019), Table 8: 1 min = 60 s, 1 h = 60 min = 3,600 s."
  ],
  "related": [
    "hours",
    "time-card",
    "work-hours",
    "minutes"
  ],
  "changelog": []
}
