{"version":3,"sources":["../src/internal/time.ts"],"names":[],"mappings":"AAmBA,QAAA,MAAM,2BAA2B,WAAW,CAAC;AAC7C,QAAA,MAAM,sBAAsB,cAAc,CAAC;AAC3C,QAAA,MAAM,sBAAsB,eAAe,CAAC;AAC5C,QAAA,MAAM,oBAAoB,iBAAiB,CAAC;AAC5C,QAAA,MAAM,mBAAmB,kBAAkB,CAAC","file":"time.d.ts","sourcesContent":["/*!\r\n   Copyright 2019 Ron Buckton\r\n\r\n   Licensed under the Apache License, Version 2.0 (the \"License\");\r\n   you may not use this file except in compliance with the License.\r\n   You may obtain a copy of the License at\r\n\r\n       http://www.apache.org/licenses/LICENSE-2.0\r\n\r\n   Unless required by applicable law or agreed to in writing, software\r\n   distributed under the License is distributed on an \"AS IS\" BASIS,\r\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n   See the License for the specific language governing permissions and\r\n   limitations under the License.\r\n*/\r\nimport { NANOS_OF_DAY } from './types';\r\n\r\n// Time utilities\r\n\r\nconst NANOSECONDS_PER_MILLISECOND = 1000000n;\r\nconst NANOSECONDS_PER_SECOND = 1000000000n;\r\nconst NANOSECONDS_PER_MINUTE = 60000000000n;\r\nconst NANOSECONDS_PER_HOUR = 3600000000000n;\r\nconst NANOSECONDS_PER_DAY = 86400000000000n;\r\n\r\n/* @internal */ export { NANOSECONDS_PER_DAY, NANOSECONDS_PER_HOUR, NANOSECONDS_PER_MINUTE, NANOSECONDS_PER_SECOND, NANOSECONDS_PER_MILLISECOND }\r\n\r\n// https://tc39.github.io/ecma262/#sec-maketime\r\n/* @internal */ export function getTime(hours: number, minutes: number, seconds: number, milliseconds: number, nanoseconds: number) {\r\n    const time =\r\n        BigInt(hours) * NANOSECONDS_PER_HOUR +\r\n        BigInt(minutes) * NANOSECONDS_PER_MINUTE +\r\n        BigInt(seconds) * NANOSECONDS_PER_SECOND +\r\n        BigInt(milliseconds) * NANOSECONDS_PER_MILLISECOND +\r\n        BigInt(nanoseconds);\r\n    return time as NANOS_OF_DAY;\r\n}\r\n\r\n/* @internal */ export interface TimeParts {\r\n    overflowDays: number;\r\n    hour: number;\r\n    minute: number;\r\n    second: number;\r\n    millisecond: number;\r\n    nanosecond: number;\r\n}\r\n\r\n/* @internal */ export const enum TimePart {\r\n    overflowDays,\r\n    hour,\r\n    minute,\r\n    second,\r\n    millisecond,\r\n    nanosecond,\r\n    all\r\n}\r\n\r\n/* @internal */ export function getTimePart<P extends TimePart>(time: NANOS_OF_DAY, part: P): P extends TimePart.all ? TimeParts : number;\r\n/* @internal */ export function getTimePart(time: NANOS_OF_DAY, part: TimePart) {\r\n    let n: bigint = time;\r\n    const overflowDaysPart = n / NANOSECONDS_PER_DAY;\r\n    if (part === TimePart.overflowDays) return Number(overflowDaysPart);\r\n    n = n % NANOSECONDS_PER_DAY;\r\n    const hourPart = n / NANOSECONDS_PER_HOUR;\r\n    if (part === TimePart.hour) return Number(hourPart);\r\n    n = n % NANOSECONDS_PER_HOUR;\r\n    const minutePart = n / NANOSECONDS_PER_MINUTE;\r\n    if (part === TimePart.minute) return Number(minutePart);\r\n    n = n % NANOSECONDS_PER_MINUTE;\r\n    const secondPart = n / NANOSECONDS_PER_SECOND;\r\n    if (part === TimePart.second) return Number(secondPart);\r\n    n = n % NANOSECONDS_PER_SECOND;\r\n    const millisecondPart = n / NANOSECONDS_PER_MILLISECOND;\r\n    if (part === TimePart.millisecond) return Number(millisecondPart);\r\n    n = n % NANOSECONDS_PER_MILLISECOND;\r\n    if (part === TimePart.nanosecond) return Number(n);\r\n    const overflowDays = Number(overflowDaysPart);\r\n    const hour = Number(hourPart);\r\n    const minute = Number(minutePart);\r\n    const second = Number(secondPart);\r\n    const millisecond = Number(millisecondPart);\r\n    const nanosecond = Number(n);\r\n    return { overflowDays, hour, minute, second, millisecond, nanosecond };\r\n}\r\n\r\n\r\n"],"sourceRoot":".."}