@himal_bhattarai/nepali-datepicker 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -272,21 +272,41 @@ getTodayBS() // → { year: 2082, month: 11, day: 22 }
|
|
|
272
272
|
/>
|
|
273
273
|
```
|
|
274
274
|
|
|
275
|
-
###
|
|
275
|
+
### Sending BS date to a backend API
|
|
276
276
|
```jsx
|
|
277
277
|
<NepaliDatePicker
|
|
278
278
|
value={date}
|
|
279
|
-
onChange={(bs
|
|
279
|
+
onChange={(bs) => {
|
|
280
280
|
setDate(bs);
|
|
281
|
-
|
|
281
|
+
|
|
282
|
+
// Send BS date as separate fields
|
|
282
283
|
fetch("/api/booking", {
|
|
283
284
|
method: "POST",
|
|
284
|
-
body: JSON.stringify({
|
|
285
|
+
body: JSON.stringify({
|
|
286
|
+
year: bs.year, // 2081
|
|
287
|
+
month: bs.month, // 11
|
|
288
|
+
day: bs.day, // 22
|
|
289
|
+
}),
|
|
285
290
|
});
|
|
286
291
|
}}
|
|
287
292
|
/>
|
|
288
293
|
```
|
|
289
294
|
|
|
295
|
+
Or as a formatted BS date string:
|
|
296
|
+
```jsx
|
|
297
|
+
onChange={(bs) => {
|
|
298
|
+
setDate(bs);
|
|
299
|
+
|
|
300
|
+
const bsFormatted = `${bs.year}-${String(bs.month).padStart(2,"0")}-${String(bs.day).padStart(2,"0")}`;
|
|
301
|
+
// → "2081-11-22"
|
|
302
|
+
|
|
303
|
+
fetch("/api/booking", {
|
|
304
|
+
method: "POST",
|
|
305
|
+
body: JSON.stringify({ date: bsFormatted }),
|
|
306
|
+
});
|
|
307
|
+
}}
|
|
308
|
+
```
|
|
309
|
+
|
|
290
310
|
---
|
|
291
311
|
|
|
292
312
|
## How the Calendar Works
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@himal_bhattarai/nepali-datepicker",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Nepali Bikram Sambat (BS) date picker React component with BS↔AD conversion",
|
|
5
5
|
"main": "./dist/nepali-datepicker.umd.js",
|
|
6
6
|
"module": "./dist/nepali-datepicker.es.js",
|