{"_id":"@blackorder/opening-hours-service","_rev":"11-163045cb9eb81fa65bd0e9d176ede80f","name":"@blackorder/opening-hours-service","dist-tags":{"latest":"1.3.2"},"versions":{"1.0.0":{"name":"@blackorder/opening-hours-service","version":"1.0.0","keywords":["opening-hours","timezone","npm"],"author":{"name":"BlackOrder"},"license":"MIT","_id":"@blackorder/opening-hours-service@1.0.0","maintainers":[{"name":"blackorder","email":"ahmedwidatalla@gmail.com"}],"homepage":"https://github.com/BlackOrder/OpeningHoursService#readme","bugs":{"url":"https://github.com/BlackOrder/OpeningHoursService/issues"},"dist":{"shasum":"59c69abf441eabeda27269de0e54d4242197ada6","tarball":"https://registry.npmjs.org/@blackorder/opening-hours-service/-/opening-hours-service-1.0.0.tgz","fileCount":12,"integrity":"sha512-0bcXFWZZxzPY1aA821ycH0+D+UTC9XlLN4N+6UQpK3DKpZGPjBsVUfF8UZRj26o/gyVnfo0D+0skdNHLxSJEYg==","signatures":[{"sig":"MEYCIQC0y+83s9WbJymXs/XPeTLga4/JNFdPWArgnLfhTcG+SgIhAPb8TIt34Xan3/mCtfvOc2gkQ9yqXprgqLKNwsT6OoI1","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":105135},"main":"./dist/cjs/index.js","type":"commonjs","types":"./dist/types/index.d.ts","module":"./dist/esm/index.mjs","exports":{".":{"import":"./dist/esm/index.mjs","require":"./dist/cjs/index.js"}},"gitHead":"8f5c00d2b192730d60db922ed77aaac89562b478","scripts":{"test":"jest","build":"npm run build:cjs && npm run build:esm","clean":"rimraf dist","prepack":"npm run clean && npm run build","prepare":"npm run build","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json && npm run rename:esm","rename:esm":"/bin/bash ./scripts/fix-mjs.sh"},"_npmUser":{"name":"blackorder","email":"ahmedwidatalla@gmail.com"},"deprecated":"Full of bugs","repository":{"url":"git+https://github.com/BlackOrder/OpeningHoursService.git","type":"git"},"_npmVersion":"10.8.2","description":"A service for managing business opening hours with timezone support","directories":{"test":"tests"},"_nodeVersion":"20.9.0","dependencies":{"date-fns-tz":"^3.1.3","opening_hours":"^3.8.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","rimraf":"^6.0.1","ts-jest":"^29.2.5","ts-node":"^10.9.2","babel-jest":"^29.7.0","typescript":"^5.6.2","@types/jest":"^29.5.13","@types/node":"^22.6.0","@babel/preset-env":"^7.25.4","@babel/preset-typescript":"^7.24.7"},"_npmOperationalInternal":{"tmp":"tmp/opening-hours-service_1.0.0_1727126274463_0.33477987306995827","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@blackorder/opening-hours-service","version":"1.0.1","keywords":["opening-hours","timezone","npm"],"author":{"name":"BlackOrder"},"license":"MIT","_id":"@blackorder/opening-hours-service@1.0.1","maintainers":[{"name":"blackorder","email":"ahmedwidatalla@gmail.com"}],"homepage":"https://github.com/BlackOrder/OpeningHoursService#readme","bugs":{"url":"https://github.com/BlackOrder/OpeningHoursService/issues"},"dist":{"shasum":"4609f0c0f479dc494391d86e006bfb66e6cbe3aa","tarball":"https://registry.npmjs.org/@blackorder/opening-hours-service/-/opening-hours-service-1.0.1.tgz","fileCount":12,"integrity":"sha512-Eu1kzXohztEhJcBT86AepOLD9C1cmcqAlyJ+Jiv9IkLCSUcHsn/n3hgWLi3dAaIOdP/ztidquERVyblj8k/5Ow==","signatures":[{"sig":"MEYCIQCYI4mu2ylFoJVI35i3+mlpsKmYkX5OhWph/GCHxZo0TQIhALma08r32MaftMRCUPHZurMtEybsX90rqB6QVMgpcwuN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":105183},"main":"./dist/cjs/index.js","type":"commonjs","types":"./dist/types/index.d.ts","module":"./dist/esm/index.mjs","exports":{".":{"import":"./dist/esm/index.mjs","require":"./dist/cjs/index.js"}},"gitHead":"410e73517a737678a01f0a74a191c8450edd2161","scripts":{"test":"jest","build":"npm run build:cjs && npm run build:esm","clean":"rimraf dist","prepack":"npm run clean && npm run build","prepare":"npm run build","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json && npm run rename:esm","rename:esm":"/bin/bash ./scripts/fix-mjs.sh"},"_npmUser":{"name":"blackorder","email":"ahmedwidatalla@gmail.com"},"deprecated":"Full of bugs","repository":{"url":"git+https://github.com/BlackOrder/OpeningHoursService.git","type":"git"},"_npmVersion":"10.8.2","description":"A service for managing business opening hours with timezone support","directories":{"test":"tests"},"_nodeVersion":"20.9.0","dependencies":{"date-fns-tz":"^3.1.3","opening_hours":"^3.8.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","rimraf":"^6.0.1","ts-jest":"^29.2.5","ts-node":"^10.9.2","babel-jest":"^29.7.0","typescript":"^5.6.2","@types/jest":"^29.5.13","@types/node":"^22.6.0","@babel/preset-env":"^7.25.4","@babel/preset-typescript":"^7.24.7"},"_npmOperationalInternal":{"tmp":"tmp/opening-hours-service_1.0.1_1727126815783_0.06611083293499176","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@blackorder/opening-hours-service","version":"1.0.2","keywords":["opening-hours","timezone","npm"],"author":{"name":"BlackOrder"},"license":"MIT","_id":"@blackorder/opening-hours-service@1.0.2","maintainers":[{"name":"blackorder","email":"ahmedwidatalla@gmail.com"}],"homepage":"https://github.com/BlackOrder/opening-hours-service#readme","bugs":{"url":"https://github.com/BlackOrder/opening-hours-service/issues"},"dist":{"shasum":"bcf71b6d18df8249bf1d02e42f57692fdff20b74","tarball":"https://registry.npmjs.org/@blackorder/opening-hours-service/-/opening-hours-service-1.0.2.tgz","fileCount":12,"integrity":"sha512-ZN7yLtvCi4nK8fYpsDrVsVVQf4OQlFYkbHzxC51vDce2bHNxrq6E19jUZAcfEeQq1RiOmHzorVsZ7gzewN5Cow==","signatures":[{"sig":"MEQCIG6i5kvsaenTDrTMvCfjCJ4B74KoXy8neR2ZAu1BLfXZAiAw/MadFwJPEVohxN3wymBcLKzGGtBcdlZ6EgotkL+t8A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137946},"main":"./dist/cjs/index.js","type":"commonjs","types":"./dist/types/index.d.ts","module":"./dist/esm/index.mjs","exports":{".":{"import":"./dist/esm/index.mjs","require":"./dist/cjs/index.js"}},"gitHead":"638cbdffb2d9da55ba0ef93456c80550a73e572c","scripts":{"test":"jest","build":"npm run build:cjs && npm run build:esm","clean":"rimraf dist","prepack":"npm run clean && npm run build","prepare":"npm run build","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json && npm run rename:esm","rename:esm":"/bin/bash ./scripts/fix-mjs.sh"},"_npmUser":{"name":"blackorder","email":"ahmedwidatalla@gmail.com"},"deprecated":"Full of bugs","repository":{"url":"git+https://github.com/BlackOrder/opening-hours-service.git","type":"git"},"_npmVersion":"10.8.2","description":"A service for managing business opening hours with timezone support","directories":{"test":"tests"},"_nodeVersion":"20.9.0","dependencies":{"date-fns-tz":"^3.1.3","opening_hours":"^3.8.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","rimraf":"^6.0.1","ts-jest":"^29.2.5","ts-node":"^10.9.2","babel-jest":"^29.7.0","typescript":"^5.6.2","@types/jest":"^29.5.13","@types/node":"^22.6.0","@babel/preset-env":"^7.25.4","@babel/preset-typescript":"^7.24.7"},"_npmOperationalInternal":{"tmp":"tmp/opening-hours-service_1.0.2_1727183405379_0.4747974777639472","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@blackorder/opening-hours-service","version":"1.1.0","keywords":["opening-hours","timezone","npm"],"author":{"name":"BlackOrder"},"license":"MIT","_id":"@blackorder/opening-hours-service@1.1.0","maintainers":[{"name":"blackorder","email":"ahmedwidatalla@gmail.com"}],"homepage":"https://github.com/BlackOrder/opening-hours-service#readme","bugs":{"url":"https://github.com/BlackOrder/opening-hours-service/issues"},"dist":{"shasum":"ed69742fe51558293814f8e122506649bbbb6351","tarball":"https://registry.npmjs.org/@blackorder/opening-hours-service/-/opening-hours-service-1.1.0.tgz","fileCount":12,"integrity":"sha512-EdMMtxnCLowpBPW0jA97L2KKfjNT86aPkw/q3HO1JpyvbXSzf+5OE6xdpB4BpW1zZNfEWmq8r6Ix61f0kBKIyg==","signatures":[{"sig":"MEUCIQCpll1qIQ3mGJinHRp/dUloHUjaJWC4TLWBqcHghqDT5AIgHZiJE07QT5K1EpNEKU4deoFpiW2Lxa/A1WTnEvHyjFc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":138945},"main":"./dist/cjs/index.js","type":"commonjs","types":"./dist/types/index.d.ts","module":"./dist/esm/index.mjs","exports":{".":{"import":"./dist/esm/index.mjs","require":"./dist/cjs/index.js"}},"gitHead":"638cbdffb2d9da55ba0ef93456c80550a73e572c","scripts":{"test":"jest","build":"npm run build:cjs && npm run build:esm","clean":"rimraf dist","prepack":"npm run clean && npm run build","prepare":"npm run build","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json && npm run rename:esm","rename:esm":"/bin/bash ./scripts/fix-mjs.sh"},"_npmUser":{"name":"blackorder","email":"ahmedwidatalla@gmail.com"},"deprecated":"Full of bugs","repository":{"url":"git+https://github.com/BlackOrder/opening-hours-service.git","type":"git"},"_npmVersion":"10.8.2","description":"A service for managing business opening hours with timezone support","directories":{"test":"tests"},"_nodeVersion":"20.9.0","dependencies":{"date-fns-tz":"^3.1.3","opening_hours":"^3.8.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","rimraf":"^6.0.1","ts-jest":"^29.2.5","ts-node":"^10.9.2","babel-jest":"^29.7.0","typescript":"^5.6.2","@types/jest":"^29.5.13","@babel/preset-env":"^7.25.4","@babel/preset-typescript":"^7.24.7"},"_npmOperationalInternal":{"tmp":"tmp/opening-hours-service_1.1.0_1727207617269_0.4616040652817701","host":"s3://npm-registry-packages"}},"1.3.0":{"name":"@blackorder/opening-hours-service","version":"1.3.0","keywords":["opening-hours","timezone","npm"],"author":{"name":"BlackOrder"},"license":"MIT","_id":"@blackorder/opening-hours-service@1.3.0","maintainers":[{"name":"blackorder","email":"ahmedwidatalla@gmail.com"}],"homepage":"https://github.com/BlackOrder/opening-hours-service#readme","bugs":{"url":"https://github.com/BlackOrder/opening-hours-service/issues"},"dist":{"shasum":"61209fad2ba193f232aad0e46a66462507e4a5b1","tarball":"https://registry.npmjs.org/@blackorder/opening-hours-service/-/opening-hours-service-1.3.0.tgz","fileCount":12,"integrity":"sha512-asmTBjkSpPENEbDaVGurtXbERtBMhhaVBe2jIyMo61jVL3lAkmrw4H8IPtJ4s9T3XAkUumc1ZnY4K9c/MXiDQQ==","signatures":[{"sig":"MEYCIQC3NusJLWgROw/OICmjxXmQNP2rBdZ+Uqtc+b5IMzXbKAIhAORGYG4rDMclX4dnzaJiPeJdmysC64acZnjs8P2r/kWu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":142590},"main":"./dist/cjs/index.js","type":"commonjs","types":"./dist/types/index.d.ts","module":"./dist/esm/index.mjs","exports":{".":{"import":"./dist/esm/index.mjs","require":"./dist/cjs/index.js"}},"gitHead":"9f417fc74f2f696c471bf565c9643b3b1cd8053e","scripts":{"test":"jest","build":"npm run build:cjs && npm run build:esm","clean":"rimraf dist","prepack":"npm run clean && npm run build","prepare":"npm run build","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json && npm run rename:esm","rename:esm":"/bin/bash ./scripts/fix-mjs.sh"},"_npmUser":{"name":"blackorder","email":"ahmedwidatalla@gmail.com"},"deprecated":"Full of bugs","repository":{"url":"git+https://github.com/BlackOrder/opening-hours-service.git","type":"git"},"_npmVersion":"10.8.2","description":"A service for managing business opening hours with timezone support","directories":{"test":"tests"},"_nodeVersion":"20.17.0","dependencies":{"date-fns-tz":"^3.1.3","opening_hours":"^3.8.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","rimraf":"^6.0.1","ts-jest":"^29.2.5","ts-node":"^10.9.2","babel-jest":"^29.7.0","typescript":"^5.6.2","@types/jest":"^29.5.13","@babel/preset-env":"^7.25.4","@babel/preset-typescript":"^7.24.7"},"_npmOperationalInternal":{"tmp":"tmp/opening-hours-service_1.3.0_1727292899766_0.6809088135976396","host":"s3://npm-registry-packages"}},"1.3.1":{"name":"@blackorder/opening-hours-service","version":"1.3.1","keywords":["opening-hours","timezone","npm"],"author":{"name":"BlackOrder"},"license":"MIT","_id":"@blackorder/opening-hours-service@1.3.1","maintainers":[{"name":"blackorder","email":"ahmedwidatalla@gmail.com"}],"homepage":"https://github.com/BlackOrder/opening-hours-service#readme","bugs":{"url":"https://github.com/BlackOrder/opening-hours-service/issues"},"dist":{"shasum":"6e6b5f86b07e271faf89797b05db082fdd47e478","tarball":"https://registry.npmjs.org/@blackorder/opening-hours-service/-/opening-hours-service-1.3.1.tgz","fileCount":12,"integrity":"sha512-3WTgb/27B3tcwaLcctCUB8WWWKyoc83yyvj6Nq3da0nZomhiNCRxCVuN5itBcA5qGPTGePD7BgQ66EJaoftgmA==","signatures":[{"sig":"MEUCIB8CyDtcPeQSwbng9QtrK85GtnDASZVjHRugchY80w2FAiEA22gOfnxWvCLuY54jxC/5o5hl+5kq4upQli0yBx+qAiE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":142590},"main":"./dist/cjs/index.js","type":"commonjs","types":"./dist/types/index.d.ts","module":"./dist/esm/index.mjs","exports":{".":{"import":"./dist/esm/index.mjs","require":"./dist/cjs/index.js"}},"gitHead":"98dd73d5c50f8126291b2340a3159b4686dd2f27","scripts":{"test":"jest","build":"npm run build:cjs && npm run build:esm","clean":"rimraf dist","prepack":"npm run clean && npm run build","prepare":"npm run build","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json && npm run rename:esm","rename:esm":"/bin/bash ./scripts/fix-mjs.sh"},"_npmUser":{"name":"blackorder","email":"ahmedwidatalla@gmail.com"},"repository":{"url":"git+https://github.com/BlackOrder/opening-hours-service.git","type":"git"},"_npmVersion":"10.8.2","description":"A service for managing business opening hours with timezone support","directories":{"test":"tests"},"_nodeVersion":"20.17.0","dependencies":{"date-fns-tz":"^3.1.3","opening_hours":"^3.8.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","rimraf":"^6.0.1","ts-jest":"^29.2.5","ts-node":"^10.9.2","babel-jest":"^29.7.0","typescript":"^5.6.2","@types/jest":"^29.5.13","@babel/preset-env":"^7.25.4","@babel/preset-typescript":"^7.24.7"},"_npmOperationalInternal":{"tmp":"tmp/opening-hours-service_1.3.1_1727292941177_0.9650110460588048","host":"s3://npm-registry-packages"}},"1.3.2":{"name":"@blackorder/opening-hours-service","version":"1.3.2","main":"./dist/cjs/index.js","module":"./dist/esm/index.mjs","types":"./dist/types/index.d.ts","exports":{".":{"require":"./dist/cjs/index.js","import":"./dist/esm/index.mjs"}},"scripts":{"build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json && npm run rename:esm","build":"npm run build:cjs && npm run build:esm","clean":"rimraf dist","rename:esm":"/bin/bash ./scripts/fix-mjs.sh","prepack":"npm run clean && npm run build","test":"jest","prepare":"npm run build"},"keywords":["opening-hours","timezone","npm"],"type":"commonjs","author":{"name":"BlackOrder"},"license":"MIT","description":"A service for managing business opening hours with timezone support","dependencies":{"date-fns-tz":"^3.1.3","opening_hours":"^3.8.0"},"devDependencies":{"@types/jest":"^29.5.13","jest":"^29.7.0","rimraf":"^6.0.1","ts-node":"^10.9.2","ts-jest":"^29.2.5","typescript":"^5.6.2"},"directories":{"test":"tests"},"repository":{"type":"git","url":"git+https://github.com/BlackOrder/opening-hours-service.git"},"bugs":{"url":"https://github.com/BlackOrder/opening-hours-service/issues"},"homepage":"https://github.com/BlackOrder/opening-hours-service#readme","_id":"@blackorder/opening-hours-service@1.3.2","gitHead":"a3a39f5c6e89ec7de4d5aa5e7d1c133fb9e121a3","_nodeVersion":"20.17.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-46sXakSYUIl15QWJDTBPCLeUYU66/piEWvEkgTJcmAG2X3Ml/nERFHrzzOYMAgMQHyxu1yVd9H9dwRB67TcW6g==","shasum":"0530438203a9fe6671b7310ad9c06bcb4a4eeb59","tarball":"https://registry.npmjs.org/@blackorder/opening-hours-service/-/opening-hours-service-1.3.2.tgz","fileCount":12,"unpackedSize":143902,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH2MZfB5Yru5pGvYSbJsbw1j1dNHC1CFAgmTGnklNOhHAiA30/3oQV+3h6Ssoq5Q90cxKfQzH7rtuPy7IuFqHzqoFA=="}]},"_npmUser":{"name":"blackorder","email":"ahmedwidatalla@gmail.com"},"maintainers":[{"name":"blackorder","email":"ahmedwidatalla@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/opening-hours-service_1.3.2_1727347490840_0.08305380130979545"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-23T21:17:54.324Z","modified":"2024-09-26T10:44:51.203Z","1.0.0":"2024-09-23T21:17:54.652Z","1.0.1":"2024-09-23T21:26:55.978Z","1.0.2":"2024-09-24T13:10:05.616Z","1.1.0":"2024-09-24T19:53:37.554Z","1.3.0":"2024-09-25T19:34:59.944Z","1.3.1":"2024-09-25T19:35:41.464Z","1.3.2":"2024-09-26T10:44:51.034Z"},"bugs":{"url":"https://github.com/BlackOrder/opening-hours-service/issues"},"author":{"name":"BlackOrder"},"license":"MIT","homepage":"https://github.com/BlackOrder/opening-hours-service#readme","keywords":["opening-hours","timezone","npm"],"repository":{"type":"git","url":"git+https://github.com/BlackOrder/opening-hours-service.git"},"description":"A service for managing business opening hours with timezone support","maintainers":[{"name":"blackorder","email":"ahmedwidatalla@gmail.com"}],"readme":"# Opening Hours Service\n\nA robust, timezone-aware service to manage business opening hours with automatic validation, time range splitting, timezone conversion, and comprehensive querying capabilities.\n\n## Installation\n\nInstall the package via npm:\n\n```bash\nnpm install @blackorder/opening-hours-service\n```\n\n## Features\n\n- **Add, update, remove, and query business opening hours.**\n- **Handles timezone conversion, automatically adjusting days and times.**\n- **Automatically validates and merges adjacent time ranges.**\n- **Supports exporting hours in different timezones.**\n- **Comprehensive API for checking if a business is currently open or closed.**\n- **Retrieves the next opening or closing time.**\n- **Identifies days without any opening hours set.**\n- **Calculates total open hours for the week.**\n- **Flexible handling of multiple open ranges per day.**\n- **Integration with the `opening_hours` library for efficient management.**\n\n## Usage\n\n### Importing the Package\n\nYou can import the `OpeningHoursService` in your project:\n\n```typescript\nimport { OpeningHoursService } from '@blackorder/opening-hours-service';\n```\n\nOr if you are using CommonJS:\n\n```typescript\nconst { OpeningHoursService } = require('@blackorder/opening-hours-service');\n```\n\n### Creating a Service Instance\n\nTo start using the service, instantiate it with optional initial data and timezone:\n\n```typescript\nconst service = new OpeningHoursService(initialHours, 'America/New_York');\n```\n\n**Parameters:**\n- `initialHours` *(optional)*: An array of `OpeningHoursSpecification` objects representing the initial opening hours data.\n- `timezone` *(optional)*: A string specifying the timezone of the input data. Defaults to the user's local timezone if not provided.\n\n### Adding Opening Hours\n\nYou can add opening hours for specific days using `addOpeningHour`:\n\n```typescript\nservice.addOpeningHour('Monday', '09:00', '17:00', 'UTC');\n```\n\nOr add multiple opening hours in a batch:\n\n```typescript\nconst additionalHours: OpeningHoursSpecification[] = [\n  {\n    '@type': 'OpeningHoursSpecification',\n    dayOfWeek: 'Tuesday',\n    opens: '10:00',\n    closes: '14:00',\n  },\n  {\n    '@type': 'OpeningHoursSpecification',\n    dayOfWeek: 'Wednesday',\n    opens: '11:00',\n    closes: '15:00',\n  },\n];\n\nservice.addOpeningHoursBatch(additionalHours, 'America/Los_Angeles');\n```\n\n### Removing Opening Hours\n\nYou can remove all opening hours for a specific day:\n\n```typescript\nservice.removeOpeningHoursForDay('Monday', 'UTC');\n```\n\n**Parameters:**\n- `dayOfWeek`: The day of the week to remove (e.g., \"Monday\").\n- `timezone` *(optional)*: The timezone in which to interpret the day of the week. Defaults to the user's local timezone if not provided.\n\n### Checking If Business is Open\n\nTo check if the business is currently open, use:\n\n```typescript\nconst isOpen = service.isOpenNow();\nconsole.log(`Is open now: ${isOpen}`);\n// Outputs: true or false\n```\n\nTo check if the business is open at a specific date and time:\n\n```typescript\nconst specificDate = new Date('2024-05-15T14:30:00');\nconst openAtSpecificTime = service.isOpenAt(specificDate);\nconsole.log(`Is open at ${specificDate}: ${openAtSpecificTime}`);\n// Outputs: true or false\n```\n\n### Exporting Opening Hours\n\nTo export the opening hours for a specific timezone:\n\n```typescript\nconst hours = service.exportOpeningHours('Asia/Tokyo');\nconsole.log(hours);\n// Outputs: Array of OpeningHoursSpecification objects in Asia/Tokyo timezone\n```\n\n### Getting the Next Change in Opening Hours\n\nRetrieve the next opening or closing time based on the current time or a specific reference time:\n\n```typescript\nconst nextChange = service.getNextChange();\nconsole.log(nextChange);\n// Output example:\n// { date: 2024-04-01T18:00:00.000Z, state: 'close' }\n\nconst specificDate = new Date('2024-04-01T10:00:00Z');\nconst nextChangeFromSpecificDate = service.getNextChange(specificDate);\nconsole.log(nextChangeFromSpecificDate);\n// Output example:\n// { date: 2024-04-01T18:00:00.000Z, state: 'close' }\n```\n\n### Calculating Total Open Hours\n\nCalculate the total number of open hours for the week:\n\n```typescript\nconst totalHours = service.getTotalOpenHours();\nconsole.log(`Total open hours this week: ${totalHours}`);\n// Outputs: Number of total open hours\n```\n\n### Example\n\nHere’s a full example demonstrating the basic usage of the `OpeningHoursService`:\n\n```typescript\nimport { OpeningHoursService } from '@blackorder/opening-hours-service';\n\n// Create an instance of the service\nconst service = new OpeningHoursService();\n\n// Add opening hours for Monday\nservice.addOpeningHour('Monday', '09:00', '17:00', 'UTC');\n\n// Check if the business is open right now\nconst isOpen = service.isOpenNow();\nconsole.log(`Is open now: ${isOpen}`);\n// Outputs: true or false\n\n// Export the opening hours in New York timezone\nconst hours = service.exportOpeningHours('America/New_York');\nconsole.log(hours);\n\n// Get the next change in opening hours\nconst nextChange = service.getNextChange();\nif (nextChange) {\n    console.log(`Next change is to ${nextChange.state} at ${nextChange.date}`);\n} else {\n    console.log('No upcoming changes in opening hours.');\n}\n\n// Remove the Monday hours \nservice.removeOpeningHoursForDay('Monday'); \n```\n\n### API Reference\n\n### OpeningHoursService\n\nThe main service class that manages opening hours.\n\n### Methods\n\n### setOpeningHours(hours: OpeningHoursSpecification[], timezone?: string): void\n\nSets the opening hours, handling timezone conversions, splitting entries spanning multiple days, sorting, and ensuring data integrity.\n\n**Parameters:**\n- `hours`: An array of `OpeningHoursSpecification` objects representing the opening hours to set.\n- `timezone` *(optional)*: A string specifying the timezone of the input data. Defaults to the user's local timezone if not provided.\n\n**Usage Example:**\n```typescript\nconst newHours: OpeningHoursSpecification[] = [\n  {\n    '@type': 'OpeningHoursSpecification',\n    dayOfWeek: 'Tuesday',\n    opens: '10:00',\n    closes: '18:00',\n  },\n  // Add more entries as needed\n];\n\nservice.setOpeningHours(newHours, 'Europe/London');\n```\n\n### addOpeningHour(dayOfWeek: string, opens: string, closes: string, timezone?: string): void\n\nAdds a new single-day opening hour entry. Converts times to the user's timezone, ensures data integrity, and handles splitting if the entry spans across days due to timezone conversion.\n\n**Parameters:**\n- `dayOfWeek`: A string representing the day of the week (e.g., `\"Monday\"`).\n- `opens`: A string representing the opening time in `HH:mm` format (e.g., `\"09:00\"`).\n- `closes`: A string representing the closing time in `HH:mm` format (e.g., `\"18:00\"`).\n- `timezone` *(optional)*: A string specifying the timezone of the input data. Defaults to the user's local timezone if not provided.\n\n**Usage Example:**\n```typescript\nservice.addOpeningHour('Wednesday', '08:00', '16:00', 'Europe/Berlin');\n```\n\n### addOpeningHoursBatch(openingHours: OpeningHoursSpecification[], timezone?: string): void\n\nAdds a batch of new opening hours entries. Converts times to the user's timezone, ensures data integrity, and handles splitting if the entries span across days due to timezone conversion.\n\n**Parameters:**\n- `openingHours`: An array of `OpeningHoursSpecification` objects representing the opening hours to add.\n- `timezone` *(optional)*: A string specifying the timezone of the input data. Defaults to the user's local timezone if not provided.\n\n**Usage Example:**\n```typescript\nconst additionalHours: OpeningHoursSpecification[] = [\n  {\n    '@type': 'OpeningHoursSpecification',\n    dayOfWeek: 'Thursday',\n    opens: '10:00',\n    closes: '20:00',\n  },\n  {\n    '@type': 'OpeningHoursSpecification',\n    dayOfWeek: 'Friday',\n    opens: '10:00',\n    closes: '22:00',\n  },\n];\n\nservice.addOpeningHoursBatch(additionalHours, 'America/Los_Angeles');\n```\n\n### removeOpeningHoursForDay(dayOfWeek: string, timezone?: string): void\n\nRemoves all opening hours entries for a specific day of the week, considering the provided timezone.\n\n**Parameters:**\n- `dayOfWeek`: A string representing the day of the week to remove (e.g., `\"Monday\"`).\n- `timezone` *(optional)*: A string specifying the timezone in which to interpret the day of the week. Defaults to the user's local timezone if not provided.\n\n**Usage Example:**\n```typescript\nservice.removeOpeningHoursForDay('Sunday', 'Asia/Kolkata');\n```\n\n### exportOpeningHours(timezone?: string): OpeningHoursSpecification[]\n\nExports the current opening hours data, converting it to a specified timezone. Handles splitting entries if the conversion causes day changes.\n\n**Parameters:**\n- `timezone` *(optional)*: A string specifying the timezone for the exported data. Defaults to the user's local timezone if not provided.\n\n**Returns:**\n- An array of `OpeningHoursSpecification` objects representing the opening hours in the specified timezone.\n\n**Usage Example:**\n```typescript\nconst exportedHours = service.exportOpeningHours('Asia/Tokyo');\nconsole.log(exportedHours);\n```\n\n### isOpenNow(): boolean\n\nChecks if the business is currently open based on the current local time.\n\n**Returns:**\n- `true` if the establishment is open now.\n- `false` otherwise.\n\n**Usage Example:**\n```typescript\nconst currentlyOpen = service.isOpenNow();\nconsole.log(`Is open now: ${currentlyOpen}`);\n```\n\n### isClosedNow(): boolean\n\nChecks if the business is currently closed based on the current local time.\n\n**Returns:**\n- `true` if the establishment is closed now.\n- `false` otherwise.\n\n**Usage Example:**\n```typescript\nconst currentlyClosed = service.isClosedNow();\nconsole.log(`Is closed now: ${currentlyClosed}`);\n```\n\n### isAlwaysOpen(): boolean\n\nDetermines if the establishment is always open without any closing times.\n\n**Returns:**\n- `true` if the establishment is always open.\n- `false` otherwise.\n\n**Usage Example:**\n```typescript\nconst alwaysOpen = service.isAlwaysOpen();\nconsole.log(`Is always open: ${alwaysOpen}`);\n```\n\n### isAlwaysClosed(): boolean\n\nDetermines if the establishment is always closed without any opening times.\n\n**Returns:**\n- `true` if the establishment is always closed.\n- `false` otherwise.\n\n**Usage Example:**\n```typescript\nconst alwaysClosed = service.isAlwaysClosed();\nconsole.log(`Is always closed: ${alwaysClosed}`);\n```\n\n### isOpenAt(date: Date): boolean\n\nChecks if the establishment is open at a specific date and time.\n\n**Parameters:**\n- `date`: A `Date` object representing the specific date and time to check.\n\n**Returns:**\n- `true` if the establishment is open at the specified time.\n- `false` otherwise.\n\n**Usage Example:**\n```typescript\nconst specificDate = new Date('2024-05-15T14:30:00');\nconst openAtSpecificTime = service.isOpenAt(specificDate);\nconsole.log(`Is open at ${specificDate}: ${openAtSpecificTime}`);\n```\n\n### isClosedAt(date: Date): boolean\n\nChecks if the establishment is closed at a specific date and time.\n\n**Parameters:**\n- `date`: A `Date` object representing the specific date and time to check.\n\n**Returns:**\n- `true` if the establishment is closed at the specified time.\n- `false` otherwise.\n\n**Usage Example:**\n```typescript\nconst specificDate = new Date('2024-05-15T20:00:00');\nconst closedAtSpecificTime = service.isClosedAt(specificDate);\nconsole.log(`Is closed at ${specificDate}: ${closedAtSpecificTime}`);\n```\n\n### getOpeningHoursInstance(): OpeningHoursInstance\n\nRetrieves the internal `OpeningHoursInstance` used by the service for managing opening hours logic.\n\n**Returns:**\n- An `OpeningHoursInstance` object.\n\n**Usage Example:**\n```typescript\nconst openingHoursInstance = service.getOpeningHoursInstance();\n// You can now use methods from OpeningHoursInstance if needed\n```\n\n### isOpenForDuration(durationInMinutes: number, date?: Date): boolean\n\nChecks if the business will remain open for a specified duration from the given date and time.\n\n**Parameters:**\n- `durationInMinutes`: A number representing the duration to check in minutes.\n- `date` *(optional)*: A `Date` object representing the reference date and time. Defaults to the current date and time if not provided.\n\n**Returns:**\n- `true` if the business will remain open for at least the specified duration.\n- `false` otherwise.\n\n**Usage Example:**\n```typescript\nconst duration = 120; // 2 hours\nconst referenceDate = new Date();\nconst willRemainOpen = service.isOpenForDuration(duration, referenceDate);\nconsole.log(`Will remain open for ${duration} minutes: ${willRemainOpen}`);\n```\n\n### isClosedForDuration(durationInMinutes: number, date?: Date): boolean\n\nChecks if the business will remain closed for a specified duration from the given date and time.\n\n**Parameters:**\n- `durationInMinutes`: A number representing the duration to check in minutes.\n- `date` *(optional)*: A `Date` object representing the reference date and time. Defaults to the current date and time if not provided.\n\n**Returns:**\n- `true` if the business will remain closed for at least the specified duration.\n- `false` otherwise.\n\n**Usage Example:**\n```typescript\nconst duration = 60; // 1 hour\nconst referenceDate = new Date();\nconst willRemainClosed = service.isClosedForDuration(duration, referenceDate);\nconsole.log(`Will remain closed for ${duration} minutes: ${willRemainClosed}`);\n```\n\n### openMinutesWindow(date?: Date): number\n\nRetrieves the number of minutes the business will remain open from the specified date and time.\n\n**Parameters:**\n- `date` *(optional)*: A `Date` object representing the reference date and time. Defaults to the current date and time if not provided.\n\n**Returns:**\n- A number representing the minutes until the next change in state (closing time). Returns `0` if currently closed.\n- Returns a maximum of `10080` minutes (7 days) if always open.\n\n**Usage Example:**\n```typescript\nconst referenceDate = new Date();\nconst minutesOpen = service.openMinutesWindow(referenceDate);\nconsole.log(`Minutes open from ${referenceDate}: ${minutesOpen}`);\n```\n\n### closeMinutesWindow(date?: Date): number\n\nRetrieves the number of minutes the business will remain closed from the specified date and time.\n\n**Parameters:**\n- `date` *(optional)*: A `Date` object representing the reference date and time. Defaults to the current date and time if not provided.\n\n**Returns:**\n- A number representing the minutes until the next change in state (opening time). Returns `0` if currently open.\n- Returns a maximum of `10080` minutes (7 days) if always closed.\n\n**Usage Example:**\n```typescript\nconst referenceDate = new Date();\nconst minutesClosed = service.closeMinutesWindow(referenceDate);\nconsole.log(`Minutes closed from ${referenceDate}: ${minutesClosed}`);\n```\n\n### getNextChange(date?: Date): NextChange | null\n\nRetrieves the next change in the opening hours (either opening or closing) from the specified date and time.\n\n**Parameters:**\n- `date` *(optional)*: A `Date` object representing the reference date and time. Defaults to the current date and time if not provided.\n\n**Returns:**\n- A `NextChange` object containing the date and the state (`'open'` or `'close'`) after the change.\n- `null` if there are no upcoming changes.\n\n**Usage Example:**\n```typescript\nconst referenceDate = new Date();\nconst nextChange = service.getNextChange(referenceDate);\nif (nextChange) {\n  console.log(`Next change at ${nextChange.date} to state: ${nextChange.state}`);\n} else {\n  console.log('No upcoming changes.');\n}\n```\n\n### getNextOpeningTime(): Date | null\n\nRetrieves the next opening time from the current time.\n\n**Returns:**\n- A `Date` object representing the next opening time.\n- `null` if there are no upcoming openings.\n\n**Usage Example:**\n```typescript\nconst nextOpening = service.getNextOpeningTime();\nif (nextOpening) {\n  console.log(`Next opening time: ${nextOpening}`);\n} else {\n  console.log('The establishment will not open again.');\n}\n```\n\n### getNextClosingTime(): Date | null\n\nRetrieves the next closing time from the current time.\n\n**Returns:**\n- A `Date` object representing the next closing time.\n- `null` if there are no upcoming closings.\n\n**Usage Example:**\n```typescript\nconst nextClosing = service.getNextClosingTime();\nif (nextClosing) {\n  console.log(`Next closing time: ${nextClosing}`);\n} else {\n  console.log('The establishment will not close again.');\n}\n```\n\n### getOpenRangePerDay(timezone?: string): OpenRangePerDay[]\n\nReturns an array with openRange for each day of the week, including the opening and closing times, with optional timezone conversion.\n\n**Parameters:**\n- `timezone` *(optional)*: The timezone to use for the openRange. Defaults to the user's local timezone if not provided.\n\n**Returns:**\n- An array of `OpenRangePerDay` objects, each containing the day of the week and its associated open ranges.\n\n**Usage Example:**\n```typescript\nconst weeklyOpenRanges = service.getOpenRangePerDay('Australia/Sydney');\nconsole.log(weeklyOpenRanges);\n```\n\n### getOpenRangeForDay(dayOfWeek: string, timezone?: string): OpenRangePerDay\n\nReturns the openRange for a single day, including the opening and closing times, with optional timezone conversion.\n\n**Parameters:**\n- `dayOfWeek`: The day of the week to retrieve the openRange for (e.g., `\"Monday\"`).\n- `timezone` *(optional)*: The timezone to use for the openRange. Defaults to the user's local timezone if not provided.\n\n**Returns:**\n- An `OpenRangePerDay` object containing the day of the week and its associated open ranges. Returns an empty `openRange` array if no hours are set for the specified day.\n\n**Usage Example:**\n```typescript\nconst mondayOpenRange = service.getOpenRangeForDay('Monday', 'Europe/Paris');\nconsole.log(mondayOpenRange);\n```\n\n### validateOpeningHours(openingHours?: OpeningHoursSpecification[]): boolean\n\nValidates the integrity of the current or provided opening hours. Ensures that opening and closing times are valid, and there are no overlaps or invalid entries.\n\n**Parameters:**\n- `openingHours` *(optional)*: An array of `OpeningHoursSpecification` objects to validate. Defaults to the current opening hours if not provided.\n\n**Returns:**\n- `true` if all opening hours are valid.\n- `false` otherwise.\n\n**Usage Example:**\n```typescript\nconst isValid = service.validateOpeningHours();\nconsole.log(`Opening hours are valid: ${isValid}`);\n```\n\n### getTotalOpenHours(): number\n\nCalculates the total number of open hours for the week based on the current opening hours data.\n\n**Returns:**\n- A number representing the total open hours for the week.\n\n**Usage Example:**\n```typescript\nconst totalOpenHours = service.getTotalOpenHours();\nconsole.log(`Total open hours this week: ${totalOpenHours}`);\n```\n\n### getDaysWithoutOpeningHours(): string[]\n\nRetrieves an array of days that have no opening hours set.\n\n**Returns:**\n- An array of strings representing the days of the week with no opening hours (e.g., `[\"Sunday\"]`).\n\n**Usage Example:**\n```typescript\nconst daysClosed = service.getDaysWithoutOpeningHours();\nconsole.log(`Days without opening hours: ${daysClosed.join(', ')}`);\n```\n\n## License\n\nThis package is released under the MIT License.\n\n## Author\n\nCreated by BlackOrder.\n\n## Support\n\nFor any issues or feature requests, please open an issue on the GitHub repository.\n\n## Contributing\n\nContributions are welcome! Please follow these steps:\n\n1. Fork the repository.\n2. Create a new branch: `git checkout -b feature/YourFeature`.\n3. Commit your changes: `git commit -m 'Add some feature'`.\n4. Push to the branch: `git push origin feature/YourFeature`.\n5. Open a pull request.\n\n## Changelog\n\nAll notable changes to this project will be documented in the `CHANGELOG.md`.\n\n## Acknowledgements\n\n- Inspired by [opening_hours.js](https://github.com/opening-hours/opening_hours.js)\n- Powered by [date-fns-tz](https://github.com/marnusw/date-fns-tz)\n\n## Frequently Asked Questions (FAQ)\n\n**Q: Does the service support multiple timezones simultaneously?**\n\n**A:** Yes, the service allows you to specify different timezones when adding or exporting opening hours.\n\n**Q: How does the service handle opening hours that span midnight?**\n\n**A:** The service does not allow opening hours that span midnight. Attempting to add such ranges will throw an error. Instead, split the opening hours into separate entries for each day.\n\n**Q: Can I retrieve the opening hours for all days at once?**\n\n**A:** Yes, you can use the `getOpenRangePerDay` method to retrieve open ranges for each day of the week.\n\n## Conclusion\n\nThe Opening Hours Service provides a comprehensive and flexible solution for managing business hours across different timezones, ensuring accurate and reliable operations. Whether you need simple open/close checks or advanced scheduling features, this service has you covered.\n","readmeFilename":"README.md"}