{"_id":"@dixxanta08/nepali-date-utils","name":"@dixxanta08/nepali-date-utils","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@dixxanta08/nepali-date-utils","version":"1.0.0","description":"A collection of utility functions for Nepali localization, including date conversions (Bikram Sambat ↔ Gregorian), number formatting in Nepali and English, regional data (districts, zones), and general Nepali helpers.","main":"index.js","scripts":{"start":"node src/index.js","test":"echo \"Error: no test specified\" && exit 1"},"author":"","license":"ISC","_id":"@dixxanta08/nepali-date-utils@1.0.0","_nodeVersion":"20.12.2","_npmVersion":"9.4.2","dist":{"integrity":"sha512-BnwWw1nYjdCnUsY6D8rq3n9KdQ1LtfALH3ADEuu/Lhtdr+sN13T6LSZ798mndilW3QCmemdGBk8j0sboyHckKQ==","shasum":"ceaf8d0892fdc25283ffb5e0e18accc041a201d1","tarball":"https://registry.npmjs.org/@dixxanta08/nepali-date-utils/-/nepali-date-utils-1.0.0.tgz","fileCount":5,"unpackedSize":1307673,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDNKpqMPnT/eb2c5l/NxYv8f2Zb9c1svOdVODu9J5UwUgIgM54BWe7N/RO8MmTctkq2z30phU1Odgchdwzu/9PlxdA="}]},"_npmUser":{"name":"dixxanta08","email":"dixantashrestha08@gmail.com","actor":{"name":"dixxanta08","email":"dixantashrestha08@gmail.com","type":"user"}},"directories":{},"maintainers":[{"name":"dixxanta08","email":"dixantashrestha08@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nepali-date-utils_1.0.0_1750840246101_0.6777039287224371"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-25T08:30:46.003Z","1.0.0":"2025-06-25T08:30:46.305Z","modified":"2025-06-25T08:30:46.561Z"},"maintainers":[{"name":"dixxanta08","email":"dixantashrestha08@gmail.com"}],"description":"A collection of utility functions for Nepali localization, including date conversions (Bikram Sambat ↔ Gregorian), number formatting in Nepali and English, regional data (districts, zones), and general Nepali helpers.","license":"ISC","readme":"# nepali-utils\r\n\r\nA comprehensive collection of utility functions for Nepali localization, focusing on date conversions between Bikram Sambat (BS) and Gregorian (AD), date formatting, and Nepali calendar utilities.\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install nepali-utils\r\n```\r\n\r\n## Usage\r\n\r\n```js\r\nconst dateUtils = require(\"@dixxanta08/nepali-date-utils\");\r\n\r\n// Example: Convert BS to AD\r\ndateUtils.convertBSToAD(\"2082-04-16\");\r\n// { ad: '2025-06-30', weekdayEn: 'Monday', weekdayNp: 'सोमवार' }\r\n```\r\n\r\n## API Reference\r\n\r\n### 1. `convertBSToAD(bsDate)`\r\n\r\nConverts a BS date string to AD date string with weekday info.\r\n\r\n- **Parameters:**\r\n  - `bsDate` (`string`): BS date in 'YYYY-MM-DD' format.\r\n- **Returns:** `{ ad: string, weekdayEn: string, weekdayNp: string }`\r\n- **Example:**\r\n  ```js\r\n  convertBSToAD(\"2082-04-16\");\r\n  // { ad: '2025-06-30', weekdayEn: 'Monday', weekdayNp: 'सोमवार' }\r\n  ```\r\n\r\n### 2. `convertADToBS(adDate)`\r\n\r\nConverts an AD date string to BS date string with weekday info.\r\n\r\n- **Parameters:**\r\n  - `adDate` (`string`): AD date in 'YYYY-MM-DD' format.\r\n- **Returns:** `{ bs: string, weekdayEn: string, weekdayNp: string }`\r\n- **Example:**\r\n  ```js\r\n  convertADToBS(\"2025-06-30\");\r\n  // { bs: '2082-04-16', weekdayEn: 'Monday', weekdayNp: 'सोमवार' }\r\n  ```\r\n\r\n### 3. `isValidBSDate(bsDate)`\r\n\r\nChecks if a BS date string is valid.\r\n\r\n- **Parameters:**\r\n  - `bsDate` (`string`): BS date in 'YYYY-MM-DD' format.\r\n- **Returns:** `boolean`\r\n- **Example:**\r\n  ```js\r\n  isValidBSDate(\"2082-04-16\"); // true\r\n  isValidBSDate(\"2082-13-01\"); // false\r\n  ```\r\n\r\n### 4. `isValidADDate(adDate)`\r\n\r\nChecks if an AD date string is valid.\r\n\r\n- **Parameters:**\r\n  - `adDate` (`string`): AD date in 'YYYY-MM-DD' format.\r\n- **Returns:** `boolean`\r\n- **Example:**\r\n  ```js\r\n  isValidADDate(\"2025-06-30\"); // true\r\n  isValidADDate(\"2025-02-30\"); // false\r\n  ```\r\n\r\n### 5. `formatBSDate(bsDate, format = 'YYYY-MM-DD')`\r\n\r\nFormats a BS date string to a custom format.\r\n\r\n- **Parameters:**\r\n  - `bsDate` (`string`): BS date string 'YYYY-MM-DD'.\r\n  - `format` (`string`): Format pattern (default: 'YYYY-MM-DD').\r\n- **Returns:** `string`\r\n- **Example:**\r\n  ```js\r\n  formatBSDate(\"2082-04-16\", \"DD/MM/YYYY\"); // '16/04/2082'\r\n  ```\r\n\r\n### 6. `formatADDate(adDate, format = 'YYYY-MM-DD')`\r\n\r\nFormats an AD date string to a custom format.\r\n\r\n- **Parameters:**\r\n  - `adDate` (`string`): AD date string 'YYYY-MM-DD'.\r\n  - `format` (`string`): Format pattern (default: 'YYYY-MM-DD').\r\n- **Returns:** `string`\r\n- **Example:**\r\n  ```js\r\n  formatADDate(\"2025-06-30\", \"DD-MM-YYYY\"); // '30-06-2025'\r\n  ```\r\n\r\n### 7. `getWeekday(bsDate, locale = 'np')`\r\n\r\nGets the weekday name for a BS date in the specified locale.\r\n\r\n- **Parameters:**\r\n  - `bsDate` (`string`): BS date string 'YYYY-MM-DD'.\r\n  - `locale` (`'np'|'en'`): Locale for weekday ('np' for Nepali, 'en' for English).\r\n- **Returns:** `string`\r\n- **Example:**\r\n  ```js\r\n  getWeekday(\"2082-04-16\", \"np\"); // 'सोमवार'\r\n  getWeekday(\"2082-04-16\", \"en\"); // 'Monday'\r\n  ```\r\n\r\n### 8. `getBSMonthName(bsDate, locale = 'np_np')`\r\n\r\nGets the month name for a BS date in the specified locale.\r\n\r\n- **Parameters:**\r\n  - `bsDate` (`string`): BS date string 'YYYY-MM-DD'.\r\n  - `locale` (`'np_np'|'en_np'`): Locale for month name.\r\n- **Returns:** `string`\r\n- **Example:**\r\n  ```js\r\n  getBSMonthName(\"2082-04-16\", \"np_np\"); // 'असोज'\r\n  getBSMonthName(\"2082-04-16\", \"en_np\"); // 'Ashoj'\r\n  ```\r\n\r\n### 9. `getADMonthName(adDate, locale = 'en_us')`\r\n\r\nGets the month name for an AD date in the specified locale.\r\n\r\n- **Parameters:**\r\n  - `adDate` (`string`): AD date string 'YYYY-MM-DD'.\r\n  - `locale` (`'en_us'`): Locale for month name.\r\n- **Returns:** `string`\r\n- **Example:**\r\n  ```js\r\n  getADMonthName(\"2025-03-15\", \"en_us\"); // 'March'\r\n  ```\r\n\r\n### 10. `addDaysBS(bsDate, days)`\r\n\r\nAdds days to a BS date and returns the resulting BS date string.\r\n\r\n- **Parameters:**\r\n  - `bsDate` (`string`): BS date string 'YYYY-MM-DD'.\r\n  - `days` (`number`): Number of days to add (can be negative).\r\n- **Returns:** `string`\r\n- **Example:**\r\n  ```js\r\n  addDaysBS(\"2082-04-16\", 5); // '2082-04-21'\r\n  addDaysBS(\"2082-04-16\", -3); // '2082-04-13'\r\n  ```\r\n\r\n### 11. `addMonthsBS(bsDate, months)`\r\n\r\nAdds months to a BS date and returns the resulting BS date string.\r\n\r\n- **Parameters:**\r\n  - `bsDate` (`string`): BS date string 'YYYY-MM-DD'.\r\n  - `months` (`number`): Number of months to add (can be negative).\r\n- **Returns:** `string`\r\n- **Example:**\r\n  ```js\r\n  addMonthsBS(\"2082-04-16\", 2); // '2082-06-16'\r\n  addMonthsBS(\"2082-04-16\", -1); // '2082-03-16'\r\n  ```\r\n\r\n### 12. `differenceInDaysBS(bsDate1, bsDate2)`\r\n\r\nGets the difference in days between two BS dates.\r\n\r\n- **Parameters:**\r\n  - `bsDate1` (`string`): First BS date string 'YYYY-MM-DD'.\r\n  - `bsDate2` (`string`): Second BS date string 'YYYY-MM-DD'.\r\n- **Returns:** `number` (bsDate2 - bsDate1)\r\n- **Example:**\r\n  ```js\r\n  differenceInDaysBS(\"2082-04-10\", \"2082-04-16\"); // 6\r\n  differenceInDaysBS(\"2082-04-16\", \"2082-04-10\"); // -6\r\n  ```\r\n\r\n### 13. `daysInMonthBS(year, month)`\r\n\r\nGets the number of days in a given BS month of a year.\r\n\r\n- **Parameters:**\r\n  - `year` (`number`): BS year.\r\n  - `month` (`number`): BS month number (1-12).\r\n- **Returns:** `number`\r\n- **Example:**\r\n  ```js\r\n  daysInMonthBS(2082, 4); // 30\r\n  ```\r\n\r\n### 14. `getCurrentBSDate()`\r\n\r\nGets the current date in BS as a string.\r\n\r\n- **Returns:** `string` (Current BS date string 'YYYY-MM-DD')\r\n- **Example:**\r\n  ```js\r\n  getCurrentBSDate(); // e.g., '2082-04-16'\r\n  ```\r\n\r\n### 15. `bsToAdDateObj(bsDate)`\r\n\r\nConverts a BS date string to a native JS Date object (AD).\r\n\r\n- **Parameters:**\r\n  - `bsDate` (`string`): BS date string 'YYYY-MM-DD'.\r\n- **Returns:** `Date`\r\n- **Example:**\r\n  ```js\r\n  bsToAdDateObj(\"2082-04-16\"); // Date object for 2025-06-30\r\n  ```\r\n\r\n### 16. `adToBsString(dateObj)`\r\n\r\nConverts a native JS Date object (AD) to a BS date string.\r\n\r\n- **Parameters:**\r\n  - `dateObj` (`Date`): JavaScript Date object.\r\n- **Returns:** `string` (BS date string 'YYYY-MM-DD')\r\n- **Example:**\r\n  ```js\r\n  adToBsString(new Date(\"2025-06-30\")); // '2082-04-16'\r\n  ```\r\n\r\n### 17. `getWeekdays(locale = 'np_np')`\r\n\r\nGets an array of weekday names in the specified locale.\r\n\r\n- **Parameters:**\r\n  - `locale` (`'np_np'|'en_us'`): Locale.\r\n- **Returns:** `string[]` (Array of weekday names starting from Sunday)\r\n- **Example:**\r\n  ```js\r\n  getWeekdays(\"np_np\"); // ['आइतबार', 'सोमवार', ...]\r\n  getWeekdays(\"en_us\"); // ['Sunday', 'Monday', ...]\r\n  ```\r\n\r\n### 18. `getMonths(locale = 'np_np')`\r\n\r\nGets an array of month names in the specified locale.\r\n\r\n- **Parameters:**\r\n  - `locale` (`'np_np'|'en_us'`): Locale.\r\n- **Returns:** `string[]` (Array of month names)\r\n- **Example:**\r\n  ```js\r\n  getMonths(\"np_np\"); // ['बैशाख', 'जेठ', ...]\r\n  getMonths(\"en_us\"); // ['Baisakh', 'Jestha', ...]\r\n  ```\r\n\r\n### 19. `getDayOfYearBS(bsDate)`\r\n\r\nGets the day of year for a BS date (1-365/366).\r\n\r\n- **Parameters:**\r\n  - `bsDate` (`string`): BS date string 'YYYY-MM-DD'.\r\n- **Returns:** `number`\r\n- **Example:**\r\n  ```js\r\n  getDayOfYearBS(\"2082-01-01\"); // 1\r\n  getDayOfYearBS(\"2082-04-16\"); // 107\r\n  ```\r\n\r\n## Data Sources\r\n\r\n- `data/dateMap.json`: Mapping between BS and AD dates.\r\n- `src/data/dateMap.json`: Mapping between BS and AD dates.\r\n- `src/data/localeData.json`: Locale data for months and weekdays.\r\n\r\n## License\r\n\r\nISC\r\n","readmeFilename":"README.md","_rev":"1-e4b9b730c5c89f09c611dd83923106ca"}