{"_id":"@tabby_ai/hijri-converter","name":"@tabby_ai/hijri-converter","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.5":{"name":"@tabby_ai/hijri-converter","version":"1.0.5","description":"Typescript port of an accurate python Hijri-Gregorian dates converter based on the Umm al-Qura calendar: https://github.com/mhalshehri/hijri-converter","contributors":[{"name":"Dmitry Volovod","email":"dmitry.volovod@tabby.ai","url":"https://github.com/dimazollo"}],"license":"MIT","keywords":["hijri","hijriah","date","converter","conversion","islamic","gregorian","ummalqura","ummulqura","Umm al-Qura","arabic","saudi-arabia"],"bugs":{"url":"https://github.com/tabby-ai/hijri-converter/issues"},"scripts":{"test":"jest && node ./tests/importCommonJS.test.cjs && node ./tests/importEsm.test.mjs","clean":"rimraf ./dist","build":"tsc -p src","clean-build":"npm run clean && npm run build","prepublishOnly":"npm run clean-build"},"devDependencies":{"@babel/core":"^7.22.10","@babel/preset-env":"^7.22.10","@babel/preset-typescript":"^7.22.5","@jest/globals":"^29.6.2","@typescript-eslint/eslint-plugin":"^6.4.0","babel-jest":"^29.6.2","eslint":"^8.47.0","eslint-config-prettier":"^9.0.0","eslint-plugin-prettier":"^5.0.0","eslint-plugin-unicorn":"^48.0.1","jest":"^29.6.2","prettier":"^3.0.2","rimraf":"^5.0.1","typescript":"^5.1.6"},"type":"commonjs","private":false,"main":"dist/index.js","engines":{"node":">=16.0.0"},"types":"./dist/index.d.ts","gitHead":"4ee082559de47fb45fbb3ea3d72e1cdc13cf6f88","_id":"@tabby_ai/hijri-converter@1.0.5","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-r5bClKrcIusDoo049dSL8CawnHR6mRdDwhlQuIgZRNty68q0x8k3Lf1BtPAMxRf/GgnHBnIO4ujd3+GQdLWzxQ==","shasum":"b664994892348a402ae7529e648c819eee39208b","tarball":"https://registry.npmjs.org/@tabby_ai/hijri-converter/-/hijri-converter-1.0.5.tgz","fileCount":27,"unpackedSize":53543,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC/EVH0/aEeSsumrTwyP30BLEr0ZaVzaZTAwHzVw3Ci/QIgZb9JJ0aZ7Zl/Tu4uTA+j9jZL8I5Y4wAu4r6z2OazPlo="}]},"_npmUser":{"name":"ivan.potapov","email":"ivan.potapov@tabby.ai"},"directories":{},"maintainers":[{"name":"dmitry.volovod","email":"dmitry.volovod@tabby.ai"},{"name":"ivan.potapov","email":"ivan.potapov@tabby.ai"},{"name":"tabbyadmin","email":"npmjs@tabby.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hijri-converter_1.0.5_1692864409007_0.6491090595224991"},"_hasShrinkwrap":false}},"time":{"created":"2023-08-24T08:06:48.918Z","1.0.5":"2023-08-24T08:06:49.207Z","modified":"2023-08-24T08:06:49.479Z"},"maintainers":[{"name":"dmitry.volovod","email":"dmitry.volovod@tabby.ai"},{"name":"ivan.potapov","email":"ivan.potapov@tabby.ai"},{"name":"tabbyadmin","email":"npmjs@tabby.ai"}],"description":"Typescript port of an accurate python Hijri-Gregorian dates converter based on the Umm al-Qura calendar: https://github.com/mhalshehri/hijri-converter","keywords":["hijri","hijriah","date","converter","conversion","islamic","gregorian","ummalqura","ummulqura","Umm al-Qura","arabic","saudi-arabia"],"contributors":[{"name":"Dmitry Volovod","email":"dmitry.volovod@tabby.ai","url":"https://github.com/dimazollo"}],"bugs":{"url":"https://github.com/tabby-ai/hijri-converter/issues"},"license":"MIT","readme":"# hijri-converter\n\nA Javascript package to convert accurately between Hijri and Gregorian dates using the Umm al-Qura calendar.\n\nThis project uses a Typescript interpretation of a date conversion algorithm written in Python by Mohammed H Alshehri - [hijri-converter](https://github.com/mhalshehri/hijri-converter).\n\nTherefore, it has the same accuracy and limitations.\n\n## Limitations\n\n- The date range supported by converter is limited to the period from the beginning of 1343 AH (1 August 1924 CE) to the end of 1500 AH (16 November 2077 CE).\n- The conversion is not intended for religious purposes where sighting of the lunar crescent at the beginning of Hijri month is still preferred.\n\n## Comparison\n\n| Item                      | hijri-converter    | moment-hijri                     |\n|:--------------------------|:-------------------|:---------------------------------|\n| Conversion range          | 1343-1500 AH       | 1356-1500 AH                     |\n| Accuracy                  | 100%               | 91,8%                            |\n| Input validation          | Yes                | No                               |\n| Typescript support        | Typescript first   | Types declarations               |\n| Functionality             | Only convert dates | Parse, manipulate, display, etc. |\n| Dependencies              | Zero-dependency    | moment                           |\n| Size (minified + gzipped) | 11.4 kB            | 74.4 kB                          |\n\n## Installation\n\n```bash\nnpm install @tabby.ai/hijri-converter\n```\n\n## Basic usage\n\n```javascript\n// CommonJS modules\nconst { gregorianToHijri } = require('@tabby.ai/hijri-converter');\n\nconst date = new Date();\nconst hijriDate = gregorianToHijri({\n  year: date.getFullYear(),\n  month: date.getMonth() + 1, // Month number in Javascript Date API is zero-based.\n  day: date.getDay(),\n});\n\nconsole.log(hijriDate); // { year: 1444, month: 7, day: 15 }\n\n// or ESModules\nimport { hijriToGregorian } from '@tabby.ai/hijri-converter';\n\nconst gregorianDate = hijriToGregorian({ year: 1444, month: 7, day: 15 });\n\nconsole.log(gregorianDate); // { year: 2023, month: 2, day: 6 }\n```\n\n## What about date formatting?\n\nThis library only converts dates. But you might not need any specific date libraries if you want to format dates. Browsers and Node.js widely support date formatting: [Date.prototype.toLocaleDateString](https://caniuse.com/?search=Date.prototype.toLocaleDateString), [Intl.DateTimeFormat](https://caniuse.com/?search=DateTimeFormat)\n\n```javascript\nconst date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));\n\nconst options = {\n  timeZone: 'UTC',\n  weekday: 'short',\n  year: 'numeric',\n  month: 'long',\n  day: 'numeric',\n};\n\n// using Date.prototype.toLocaleDateString method\nconsole.log(date.toLocaleDateString('ar-SA-u-ca-islamic-umalqura', options)); // -> \"الخميس، ٧ صفر ١٤٣٤ هـ\"\nconsole.log(date.toLocaleDateString('en-SA-u-ca-islamic-umalqura', options)); // -> \"Thu, Safar 7, 1434 AH\"\n\n// or using Intl.DateTimeFormat API\nconst arSaFormatter = new Intl.DateTimeFormat(\n  'ar-SA-u-ca-islamic-umalqura',\n  options\n);\nconst enSaFormatter = new Intl.DateTimeFormat(\n  'en-SA-u-ca-islamic-umalqura',\n  options\n);\n\nconsole.log(arSaFormatter.format(date)); // -> 'الخميس، ٧ صفر ١٤٣٤ هـ'\nconsole.log(enSaFormatter.format(date)); // -> \"Thu, Safar 7, 1434 AH\"\n```\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n","readmeFilename":"README.md"}