Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/babel/traverse-7.23.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ashiishme authored Dec 5, 2023
2 parents 3e469ba + ece93b3 commit 667f3eb
Show file tree
Hide file tree
Showing 29 changed files with 492 additions and 471 deletions.
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

.github
.gitignore
/docs
src/**/*.test.ts
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Ask Buddie

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ Here's a quick guide to get started with the `BikramSambat` class:
### Import the Class

```javascript
import { BikramSambat } from '@askbuddie/bikram-sambat';
import BikramSambat from '@askbuddie/bikram-sambat'
```

### Initialize a Date

You can create a `BikramSambat` instance using different initialization methods:

```javascript
const date1 = new BikramSambat('2080-05-15'); // Initialize with a date string
const date2 = new BikramSambat(); // Initialize with the current date
const date1 = new BikramSambat('2080-05-15') // Initialize with a date string
const date2 = new BikramSambat() // Initialize with the current date
```

## Manipulating Dates
Expand All @@ -46,56 +46,56 @@ const date2 = new BikramSambat(); // Initialize with the current date
Retrieve individual date components:

```javascript
const year = date1.getYear(); // 2080
const month = date1.getMonth(); // 5
const day = date1.getDay(); // 15
const year = date1.getYear() // 2080
const month = date1.getMonth() // 5
const day = date1.getDay() // 15
```

### Set Components

Update date components:

```javascript
date1.setYear(2079);
date1.setMonth(6);
date1.setDay(20);
date1.setYear(2079)
date1.setMonth(6)
date1.setDay(20)
```

### Formatting

Format dates as strings:

```javascript
const formattedDate = date1.format('YYYY-MM-DD'); // "2080-05-15"
const dateString = date1.toString(); // "2080-05-15"
const formattedDate = date1.format('YYYY-MM-DD') // "2080-05-15"
const dateString = date1.toString() // "2080-05-15"
```

## Navigation and Comparison

Navigate through dates and perform comparisons:

```javascript
const prevYear = date1.getPreviousYear(); // 2079
const nextYear = date1.getNextYear(); // 2081
const prevYear = date1.getPreviousYear() // 2079
const nextYear = date1.getNextYear() // 2081

const isSameMonth = date1.isSameMonth(date2); // true
const isAfter = date1.isAfter(date2); // true
const isSameMonth = date1.isSameMonth(date2) // true
const isAfter = date1.isAfter(date2) // true
```

## Conversion and Retrieval

Convert dates between the Bikram Sambat and Gregorian calendars:

```javascript
const gregorianDate = date1.toAD(); // JavaScript Date object
const bsDate = BikramSambat.fromAD(gregorianDate);
const gregorianDate = date1.toAD() // JavaScript Date object
const bsDate = BikramSambat.fromAD(gregorianDate)
```

Retrieve relative dates:

```javascript
const prevDay = date1.getPreviousDay();
const weekStart = date1.getWeekStartDate();
const prevDay = date1.getPreviousDay()
const weekStart = date1.getWeekStartDate()
```

## Full Documentation
Expand Down
6 changes: 3 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bikram-sambat-docs",
"version": "0.0.1",
"description": "Documentation for Bikram Sambat date picker by Ask Buddie",
"name": "@askbuddie/bikram-sambat-docs",
"version": "1.0.0",
"description": "Documentation for Bikram Sambat library by Ask Buddie",
"scripts": {
"dev": "next dev",
"build": "next build",
Expand Down
9 changes: 0 additions & 9 deletions docs/pages/fetching-relative-dates.mdx
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
## Fetching Relative Dates

The `BikramSambat` class provides methods to fetch relative dates.

### `getPreviousDay(): BikramSambat`

Returns the previous day of the current Bikram Sambat date.

```jsx copy
const date = new BikramSambat('2078-05-15')
const prevDay = date.getPreviousDay() // Date of the previous day
```
8 changes: 8 additions & 0 deletions docs/pages/fetching-relative-dates/get-previous-day.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### `getPreviousDay(): BikramSambat`

Returns the previous day of the current Bikram Sambat date.

```jsx copy
const date = new BikramSambat('2078-05-15')
const prevDay = date.getPreviousDay() // Date of the previous day
```
2 changes: 1 addition & 1 deletion docs/pages/initialization/_meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"with-date-string": "Initializing with a Date String",
"with-another-date-instance": "Initializing with Another BikramSambat Instance",
"default-initilization": "Default Initialization"
"default-initialization": "Default Initialization"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file removed docs/public/logo.png
Binary file not shown.
11 changes: 3 additions & 8 deletions docs/theme.config.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import React from 'react'
import { DocsThemeConfig } from 'nextra-theme-docs'
import Image from 'next/image'
import Link from 'next/link'
const config: DocsThemeConfig = {
const config = {
logo: (
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
<Image src={'/logo.png'} height={50} width={50} alt="askbuddie logo" />
Bikram Sambat
</div>
),
Expand All @@ -26,10 +23,8 @@ const config: DocsThemeConfig = {
</div>
)
},
primaryHue: {
light: 15,
dark: 20
},
primaryHue: 1,
primarySaturation: 77,
useNextSeoProps: () => ({
titleTemplate: '%s – Bikram Sambat'
})
Expand Down
25 changes: 15 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "nepali-date-picker",
"version": "0.0.1",
"description": "A library to support dates according to Bikram Sambat Calendar.",
"main": "src/index.ts",
"name": "@askbuddie/bikram-sambat",
"version": "1.0.0",
"description": "A JS library for Nepali dates. Developed by Ask Buddie, this NPM library simplifies working with the Nepali calendar in JavaScript. It offers inuitive API methods making Nepali date handling effortless.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "jest",
"test:watch": "jest --watchAll",
Expand All @@ -12,19 +13,20 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/askbuddie/nepali-date-picker.git"
"url": "git+https://github.com/askbuddie/bikram-sambat.git"
},
"keywords": [
"nepali-date-picker",
"bikram-sambat",
"nepali-date"
"nepali-date",
"nepali-date-js"
],
"author": "",
"author": "Ask Buddie <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/askbuddie/nepali-date-picker/issues"
"url": "https://github.com/askbuddie/bikram-sambat/issues"
},
"homepage": "https://github.com/askbuddie/nepali-date-picker#readme",
"homepage": "https://github.com/askbuddie/bikram-sambat#readme",
"devDependencies": {
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.3.0",
Expand All @@ -34,5 +36,8 @@
"prettier": "^3.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
}
},
"files": [
"dist"
]
}
4 changes: 2 additions & 2 deletions src/BikramSambat.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BikramSambat from 'BikramSambat'
import { InvalidDate } from 'data'
import { BikramSambat } from './BikramSambat'
import { InvalidDate } from './data'
describe('BikramSambat Class', () => {
it('should create an instance of BikramSambat with empty constructor', () => {
const bikramSambat = new BikramSambat()
Expand Down
19 changes: 10 additions & 9 deletions src/BikramSambat.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { format } from 'format'
import { isDayValid, parse } from 'parser'
import { DateFormat, InvalidDate } from 'data'
import { getDaysFromBsNewYear } from 'utils/getDaysFromBsNewYear'
import { addDaysToGregorianDate } from 'utils/addDaysToGregorianDate'
import { format } from './format'
import { isDayValid, parse } from './parser'
import { getDaysFromBsNewYear } from './utils/getDaysFromBsNewYear'
import { addDaysToGregorianDate } from './utils/addDaysToGregorianDate'
import {
NepaliDaysData,
NewYearMappingData,
NepaliMonthsData,
DaysInMonthsMappingData,
DateFormat,
InvalidDate,
type LanguageCode
} from './data'
import { type Month } from 'data/nepali-months'
import { getDaysBetweenTwoAdDates } from 'utils/getDaysBetweenTwoAdDates'
import { getNewYearDateInfo } from 'utils/getNewYearDateInfo'
import { type Month } from './data/nepali-months'
import { getDaysBetweenTwoAdDates } from './utils/getDaysBetweenTwoAdDates'
import { getNewYearDateInfo } from './utils/getNewYearDateInfo'

export default class BikramSambat {
export class BikramSambat {
private static readonly nepaliDays = NepaliDaysData
private static readonly newYearMap = NewYearMappingData
private static readonly nepaliMonths = NepaliMonthsData
Expand Down
6 changes: 3 additions & 3 deletions src/format.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { format } from 'format'
import BikramSambat from 'BikramSambat'
import { InvalidDate } from 'data'
import { format } from './format'
import { BikramSambat } from './BikramSambat'
import { InvalidDate } from './data'
describe('Date Formatting', () => {
it('should format date to YYYY', () => {
const date = new BikramSambat('2079-8-15')
Expand Down
6 changes: 3 additions & 3 deletions src/format.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BikramSambat from 'BikramSambat'
import { NepaliMonthsNameEn, type DateFormat, InvalidDate } from 'data'
import { generateDateFormatOrder } from 'utils/generateDateFormatOrder'
import { BikramSambat } from './BikramSambat'
import { NepaliMonthsNameEn, type DateFormat, InvalidDate } from './data'
import { generateDateFormatOrder } from './utils/generateDateFormatOrder'

/**
* Formats a BikramSambat date into the specified format.
Expand Down
7 changes: 2 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import BikramSambat from 'BikramSambat';
const NepaliDateLib = {
BikramSambat
}
import { BikramSambat } from './BikramSambat'

export default NepaliDateLib;
export default BikramSambat
2 changes: 1 addition & 1 deletion src/isDayValid.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isDayValid } from 'parser'
import { isDayValid } from './parser'

describe('isDayValid (Bikram Sambat Calendar)', () => {
it('should return true for valid day', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/parser.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InvalidDate } from 'data'
import { InvalidDate } from './data'
import { parse } from './parser'
describe('Date Parsing', () => {
it('should parse YYYY format', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
InvalidDate,
NepaliMonthsNameEn,
type ErrorInvalidDate
} from 'data'
import { generateDateFormatOrder } from 'utils/generateDateFormatOrder'
} from './data'
import { generateDateFormatOrder } from './utils/generateDateFormatOrder'

type ParseResult = {
year?: number
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getDaysFromBsNewYear.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DaysInMonthsMappingData } from 'data'
import { DaysInMonthsMappingData } from '../data'
import { getDaysFromBsNewYear } from './getDaysFromBsNewYear'

describe('getDaysFromBsNewYear', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getDaysFromBsNewYear.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DaysInMonthsMappingData } from 'data'
import { DaysInMonthsMappingData } from '../data'

/**
*
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getNewYearDateInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NewYearMappingData } from 'data'
import { NewYearMappingData } from '../data'

interface DateInfo {
bsYear: number
Expand Down
20 changes: 7 additions & 13 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"compilerOptions": {
"lib": [
"ESNext"
],
"lib": ["ESNext"],
"target": "es2020",
"module": "NodeNext",
"removeComments": true,
Expand All @@ -12,24 +10,20 @@
"allowSyntheticDefaultImports": true,
"outDir": "dist",
"strict": true,
"lib": [
"es2022",
"dom"
],
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"moduleResolution": "node",
"moduleResolution": "NodeNext",
"baseUrl": "./src",
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"incremental": true,
"allowUnreachableCode": false,
"alwaysStrict": true
"alwaysStrict": true,
"declaration": true,
"declarationMap": true
},
"include": [
"src/**/*"
]
}
"include": ["src/**/*"]
}
Loading

0 comments on commit 667f3eb

Please sign in to comment.