Skip to content

Commit 4f33527

Browse files
authored
Enhance README with function descriptions and usage examples
- Added descriptions for each function in the bikram-sambat library - Included usage examples for converting between Gregorian and Bikram Sambat dates - Updated sections on formatting and error handling
1 parent c730b32 commit 4f33527

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed

README.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,142 @@ Javascript and Java utilities for converting between the Nepali Bikram Sambat (V
2424
console.log(bs.toBik_text('2017-03-28'));
2525
> १५ चैत २०७३
2626

27+
## Functions
28+
29+
### `daysInMonth(year, month)`
30+
31+
Returns the number of days in a given month of a specific year in the Bikram Sambat calendar.
32+
33+
**Parameters:**
34+
- `year` (number): The Bikram Sambat year.
35+
- `month` (number): The month (1-12).
36+
37+
**Returns:**
38+
- `number`: The number of days in the specified month of the given year.
39+
40+
**Example:**
41+
```javascript
42+
const days = daysInMonth(2079, 5); // 30
43+
```
44+
45+
### `toBik(greg)`
46+
47+
Converts a Gregorian date to Bikram Sambat.
48+
49+
**Parameters:**
50+
- `greg` (string): The Gregorian date in ISO format (e.g., '2024-07-24').
51+
52+
**Returns:**
53+
- `object`: An object representing the Bikram Sambat date with `year`, `month`, and `day`.
54+
55+
**Example:**
56+
```javascript
57+
const bsDate = toBik('2024-07-24');
58+
// { year: 2081, month: 4, day: 9 }
59+
```
60+
61+
### `toDev(year, month, day)`
62+
63+
Converts a Bikram Sambat date to Devanagari script.
64+
65+
**Parameters:**
66+
- `year` (number): The Bikram Sambat year.
67+
- `month` (number): The Bikram Sambat month (1-12).
68+
- `day` (number): The Bikram Sambat day.
69+
70+
**Returns:**
71+
- `object`: An object with the Devanagari script representation of the day, month, and year.
72+
73+
**Example:**
74+
```javascript
75+
const devanagariDate = toDev(2081, 4, 9);
76+
// { day: '०९', month: 'साउन', year: '२०८१' }
77+
```
78+
79+
### `toBik_euro(greg)`
80+
81+
Converts a Gregorian date to Bikram Sambat in the format `YYYY-MM-DD`.
82+
83+
**Parameters:**
84+
- `greg` (string): The Gregorian date in ISO format (e.g., '2024-07-24').
85+
86+
**Returns:**
87+
- `string`: The Bikram Sambat date in `YYYY-MM-DD` format.
88+
89+
**Example:**
90+
```javascript
91+
const bsDateStr = toBik_euro('2024-07-24');
92+
// '2081-04-09'
93+
```
94+
95+
### `toBik_dev(greg)`
96+
97+
Converts a Gregorian date to Bikram Sambat in Devanagari script.
98+
99+
**Parameters:**
100+
- `greg` (string): The Gregorian date in ISO format (e.g., '2024-07-24').
101+
102+
**Returns:**
103+
- `string`: The Bikram Sambat date in Devanagari script.
104+
105+
**Example:**
106+
```javascript
107+
const devanagariBsDateStr = toBik_dev('2024-07-24');
108+
// '०९ साउन २०८१'
109+
```
110+
111+
### `toBik_text(greg)`
112+
113+
Converts a Gregorian date to a textual representation of the Bikram Sambat date.
114+
115+
**Parameters:**
116+
- `greg` (string): The Gregorian date in ISO format (e.g., '2024-07-24').
117+
118+
**Returns:**
119+
- `string`: The Bikram Sambat date in textual format (e.g., '09 साउन 2081').
120+
121+
**Example:**
122+
```javascript
123+
const bsDateText = toBik_text('2024-07-24');
124+
// '०९ साउन २०८१'
125+
```
126+
127+
### `toGreg(year, month, day)`
128+
129+
Converts a Bikram Sambat date to Gregorian.
130+
131+
**Parameters:**
132+
- `year` (number): The Bikram Sambat year.
133+
- `month` (number): The Bikram Sambat month (1-12).
134+
- `day` (number): The Bikram Sambat day.
135+
136+
**Returns:**
137+
- `object`: An object representing the Gregorian date with `year`, `month`, and `day`.
138+
139+
**Example:**
140+
```javascript
141+
const gregDate = toGreg(2081, 4, 9);
142+
// { year: 2024, month: 7, day: 24 }
143+
```
144+
145+
### `toGreg_text(year, month, day)`
146+
147+
Converts a Bikram Sambat date to Gregorian in `YYYY-MM-DD` format.
148+
149+
**Parameters:**
150+
- `year` (number): The Bikram Sambat year.
151+
- `month` (number): The Bikram Sambat month (1-12).
152+
- `day` (number): The Bikram Sambat day.
153+
154+
**Returns:**
155+
- `string`: The Gregorian date in `YYYY-MM-DD` format.
156+
157+
**Example:**
158+
```javascript
159+
const gregDateStr = toGreg_text(2081, 4, 9);
160+
// '2024-07-24'
161+
```
162+
27163

28164
# Java
29165

0 commit comments

Comments
 (0)