{"id":15286997,"url":"https://github.com/subeshb1/nepali-date","last_synced_at":"2025-04-04T14:03:27.357Z","repository":{"id":33132328,"uuid":"152791080","full_name":"subeshb1/Nepali-Date","owner":"subeshb1","description":"📅 A small JS Library to convert English Date to Nepali and Vice Versa","archived":false,"fork":false,"pushed_at":"2025-03-12T06:32:58.000Z","size":1017,"stargazers_count":58,"open_issues_count":3,"forks_count":27,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T13:50:57.197Z","etag":null,"topics":["ad-bs","ad-to-bs","bikram-samvat","bikram-samwat","bikram-samwat-converter","bs","calendar","date-converter","datetime","deno","javascript","js-library","nepal","nepali","nepali-calendar","nepali-date","nepali-date-converter","nepali-dates","nepalidate","typescript"],"latest_commit_sha":null,"homepage":"https://subeshb1.github.io/Nepali-Date/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/subeshb1.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"code-of-conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-12T18:16:15.000Z","updated_at":"2025-04-02T10:34:54.000Z","dependencies_parsed_at":"2024-03-27T09:28:29.888Z","dependency_job_id":"397fdc06-39e1-419e-a2bd-4cc80fb350a4","html_url":"https://github.com/subeshb1/Nepali-Date","commit_stats":{"total_commits":74,"total_committers":5,"mean_commits":14.8,"dds":0.08108108108108103,"last_synced_commit":"acdb624eb934bc620f3986a9a9b42c45226c1a4f"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subeshb1%2FNepali-Date","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subeshb1%2FNepali-Date/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subeshb1%2FNepali-Date/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subeshb1%2FNepali-Date/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/subeshb1","download_url":"https://codeload.github.com/subeshb1/Nepali-Date/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247190235,"owners_count":20898700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ad-bs","ad-to-bs","bikram-samvat","bikram-samwat","bikram-samwat-converter","bs","calendar","date-converter","datetime","deno","javascript","js-library","nepal","nepali","nepali-calendar","nepali-date","nepali-date-converter","nepali-dates","nepalidate","typescript"],"created_at":"2024-09-30T15:20:14.979Z","updated_at":"2025-04-04T14:03:27.319Z","avatar_url":"https://github.com/subeshb1.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nepali-Date\n\nA small Javascript/Typescript Library to convert English Date to Nepali and Vice Versa.\n\n[![Publish](https://github.com/subeshb1/Nepali-Date/actions/workflows/publish.yml/badge.svg)](https://github.com/subeshb1/Nepali-Date/actions/workflows/publish.yml) ![Release version](https://img.shields.io/github/v/release/subeshb1/nepali-date)\n\n## Installation\n\nCDN:\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/nepali-date-converter/dist/nepali-date-converter.umd.js\"\u003e\u003c/script\u003e\n```\n\nNode JS:\n\n```sh\nnpm i nepali-date-converter\n```\n\n```js\nimport NepaliDate from 'nepali-date-converter'\n// or\n\nconst NepaliDate = require('nepali-date-converter');\n```\n\nDeno:\n\n```js\nimport NepaliDate from 'https://cdn.jsdelivr.net/npm/nepali-date-converter/dist/nepali-date-converter.es5.js'\n```\n\n## Basic Usage\n\n```js\n// NepaliDate (year,month,date)\nlet date1 = new NepaliDate(2054, 5, 24)\n// Javascript Date object\nnew NepaliDate(2051, 5, 24).toJsDate()\n// formatting\ndate1.format('ddd, DD MMMM YYYY') // 'Monday, 24 Aswin 2051'\n// update date\ndate1.setDate(10)\ndate1.setMonth(1)\ndate1.setYear(2054)\n```\n\n## API\n\n### Constructors\n\n#### constructor(value?: string | number | Date)\n\n**String**\n\nProvide a valid Nepali date string. The current supported formats are:\n\n```\nYYYY/MM/DD\nYYYY-MM-DD\nYYYY MM DD\nDD/MM/YYYY\nDD-MM-YYYY\nDD MM YYYY\n```\n\nExample:\n\n```js\nnew NepaliDate('2051/02/01') // YYYY/MM/DD\nnew NepaliDate('2051-02-01')\nnew NepaliDate('2051 02 01')\nnew NepaliDate('01/02/2051') // DD/MM/YYYY\nnew NepaliDate('01-02-2051')\nnew NepaliDate('01 02 2051')\n```\n\n**Number**\n\nThe number value represents the UTC timestamp that will be converted to Nepali date.\n\nExample:\n\n```js\nnew NepaliDate(1589638162879)\n```\n\n**Date**\n\nJavascript Date object\n\nExample:\n\n```js\nnew NepaliDate(new Date(2020, 10, 10))\n```\n\n**Empty constructor**\n\nIf no values are provided, the current day date will be converted to Nepali date.\n\n```js\nnew NepaliDate()\n```\n\n#### constructor(year: number, monthIndex: number, date: number)\n\nThis constructor takes year, monthIndex i.e 0-11, and date.\n\nExample:\n\n```js\nnew NepaliDate(2051, 0, 1) // This date represents Baisakh 1, 2051\n```\n\n### getYear(): number\n\nGet Nepali date year.\n\n### getMonth(): number\n\nGet Nepali month index.\n\n```\nBaisakh =\u003e 0\nJestha =\u003e 1\nAsar =\u003e 2\nShrawan =\u003e 3\nBhadra =\u003e 4\nAswin =\u003e 5\nKartik =\u003e 6\nMangsir =\u003e 7\nPoush =\u003e 8\nMagh =\u003e 9\nFalgun =\u003e 10\nChaitra =\u003e 11\n```\n\n### getDate(): number\n\nGet Nepali date for the month\n\n### getDay(): number\n\nGet Week day index for the date.\n\n### toJsDate(): Date\n\nReturns Javascript Date converted from nepali date.\n\n### getBS(): IYearMonthDate\n\nReturns Nepali date fields in an object implementing IYearMonthDate\n\n```js\n{\n    year: 2052,\n    month: 10,\n    date: 10,\n    day: 0\n}\n```\n\n### getAD(): IYearMonthDate\n\nReturns AD date fields in an object implementing IYearMonthDate\n\nExample:\n\n```js\n{\n    year: 2019,\n    month: 10,\n    date: 10,\n    day: 0\n}\n```\n\n### getDateObject(): IAdBs\n\nReturns an object with AD and BS object implementing IYearMonthDate\n\nExample:\n\n```js\n{\n    BS: {\n        year: 2052,\n        month: 10,\n        date: 10,\n        day: 0\n    },\n    AD: {\n        year: 2019,\n        month: 10,\n        date: 10,\n        day: 0\n    },\n\n}\n```\n\n### format(formatString: string, language: 'np' | 'en'): string\n\nFormat Nepali date string based on format string.\n\n```\nYYYY - 4 digit of year (2077)\nYYY  - 3 digit of year (077)\nYY   - 2 digit of year (77)\nM    - month number (1 - 12)\nMM   - month number with 0 padding (01 - 12)\nMMM  - short month name (Bai, Jes, Asa, Shr, etc.)\nMMMM - full month name (Baisakh, Jestha, Asar, ...)\nD    - Day of Month (1, 2, ... 31, 32)\nDD   - Day of Month with zero padding (01, 02, ...)\nd    - Week day (0, 1, 2, 3, 4, 5, 6)\ndd   - Week day in short format (Sun, Mon, ..)\nddd  - Week day in long format (Sunday, Monday, ...)\n```\n\nSet language to 'np' for nepali format. The strings can be combined in any way to create desired format.\n\n```js\nlet a = new NepaliDate(2054, 10, 10)\na.format('YYYY/MM/DD') // '2054/11/10'\na.format('YYYY MM DD') // '2054 11 10'\na.format('YYYY') // '2054'\na.format('ddd DD, MMMM YYYY') // 'Sunday 10, Falgun 2054'\na.format('To\\\\day is ddd DD, MMMM YYYY') // 'Today is Sunday 10, Falgun 2054', Note: use '\\\\' to escape [YMDd]\na.format('DD/MM/YYYY', 'np') //' १०/११/२०५४'\na.format('dd', 'np') // 'आइतबार'\na.format('ddd DD, MMMM YYYY', 'np') // 'आइतबार १०, फाल्गुण २०५४'\n// Set static variable to 'np' for default Nepali language\nNepaliDate.language = 'np'\na.format('ddd DD, MMMM YYYY') // 'आइतबार १०, फाल्गुण २०५४'\n```\n\n### setYear(year: number)\n\nSet year in the current date object. It only takes positive value i.e Nepali Year\n\nExample:\n\n```js\nlet a = new NepaliDate(2054, 10, 10)\na.setYear(2053) // will make date NepaliDate(2053,10,15);\n```\n\n### setMonth(month: number)\n\nSet month in the current date object. It can be positive or negative. Positive values within the month\nwill update the month only and more then month mill increment month and year. Negative value will deduct month and year depending on the value.\nIt is similar to javascript Date API.\n\nExample:\n\n```js\nlet a = new NepaliDate(2054, 10, 10)\na.setMonth(1) // will make date NepaliDate(2054,1,10);\na.setMonth(-1) // will make date NepaliDate(2053,11,10); To go back to previous month(s) in same or previous year \na.setMonth(12) // will make date NepaliDate(2054,0,10); To go ahead to coming month(s) in same or coming year\n```\n\n### setDate(date: number)\n\nSet date in the current date object. It can be positive or negative. Positive values within the month\nwill update the date only and more then month mill increment month and year. Negative value will deduct month and year depending on the value.\nIt is similar to javascript Date API.\n\nExample:\n\n```js\nlet a = new NepaliDate(2054, 10, 10)\na.setDate(11) // will make date NepaliDate(2054,10,11);\na.setDate(-1) // will make date NepaliDate(2054,9,29); To go back to dates from previous months\na.setDate(45) // will make date NepaliDate(2054,10,15); To go ahead to dates in coming months\n```\n\n### static parse(dateString: string): NepaliDate\n\nReturns new Nepali Date from the string date format\nSimilar to calling constructor with string parameter\n\n### static now(): NepaliDate\n\nReturns new Nepali Date converted form current day date.\nSimilar to calling empty constructor\n\n### static fromAD(date: Date): NepaliDate\n\nReturns new converted Nepali Date from the provided Javascript Date.\nIt is similar to passing string as constructor\n\n## Contributing Guide\n\n```bash\n# Fork the repo\nhttps://github.com/subeshb1/Nepali-Date\n\n# Clone your forked repo\n$ git clone git@github.com:subeshb1/Nepali-Date.git\n\n$ npm install\n\n# Create a new branch for you.\n$ git pull origin master # Pull the latest master\n$ git checkout new-branch # Checkout to your new branch\n\n# Run test\nnpm run test\n\n# Commit the changes\n$ npm run commit\n\n# Push your changes and\n$ git push\n\n# Make a pull request of your newly changed branch\n[https://github.com/subeshb1/Nepali-Date/compare](https://github.com/subeshb1/Nepali-Date/compare)\n\n```\n\n## Fixing dates and adding future data\n\nThe length of month can change for the future dates. Update the `date-config-ts` files with the number of days in respective months to fix the issue. Order the data in ascending order\n\n## Maintainer\n\n- [Subesh Bhandari](https://twitter.com/subesh1)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubeshb1%2Fnepali-date","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsubeshb1%2Fnepali-date","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubeshb1%2Fnepali-date/lists"}