Skip to content

Commit

Permalink
♻️ fix the import path and update readme error
Browse files Browse the repository at this point in the history
  • Loading branch information
ashiishme committed Dec 4, 2023
1 parent b4ef0d1 commit 40d266b
Show file tree
Hide file tree
Showing 15 changed files with 439 additions and 441 deletions.
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"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": "src/index.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "jest",
"test:watch": "jest --watchAll",
Expand Down
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
18 changes: 6 additions & 12 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,10 +10,6 @@
"allowSyntheticDefaultImports": true,
"outDir": "dist",
"strict": true,
"lib": [
"es2022",
"dom"
],
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
Expand All @@ -27,9 +21,9 @@
"isolatedModules": true,
"incremental": true,
"allowUnreachableCode": false,
"alwaysStrict": true
"alwaysStrict": true,
"declaration": true,
"declarationMap": true
},
"include": [
"src/**/*"
]
}
"include": ["src/**/*"]
}
Loading

0 comments on commit 40d266b

Please sign in to comment.