django-npdatetime 0.1.0__py3-none-any.whl
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.
- django_npdatetime-0.1.0.dist-info/METADATA +397 -0
- django_npdatetime-0.1.0.dist-info/RECORD +23 -0
- django_npdatetime-0.1.0.dist-info/WHEEL +5 -0
- django_npdatetime-0.1.0.dist-info/licenses/LICENSE +21 -0
- django_npdatetime-0.1.0.dist-info/top_level.txt +1 -0
- npdatetime_django/__init__.py +22 -0
- npdatetime_django/apps.py +13 -0
- npdatetime_django/forms.py +239 -0
- npdatetime_django/models.py +198 -0
- npdatetime_django/static/npdatetime_django/css/date_picker.css +746 -0
- npdatetime_django/static/npdatetime_django/js/date_picker.min.js +1381 -0
- npdatetime_django/static/npdatetime_django/js/pkg/README.md +345 -0
- npdatetime_django/static/npdatetime_django/js/pkg/npdatetime_wasm.d.ts +205 -0
- npdatetime_django/static/npdatetime_django/js/pkg/npdatetime_wasm.js +813 -0
- npdatetime_django/static/npdatetime_django/js/pkg/npdatetime_wasm_bg.wasm +0 -0
- npdatetime_django/static/npdatetime_django/js/pkg/npdatetime_wasm_bg.wasm.d.ts +36 -0
- npdatetime_django/static/npdatetime_django/js/pkg/package.json +15 -0
- npdatetime_django/templates/npdatetime_django/widgets/date_picker.html +28 -0
- npdatetime_django/templates/npdatetime_django/widgets/date_range.html +25 -0
- npdatetime_django/templatetags/__init__.py +259 -0
- npdatetime_django/templatetags/nepali_date.py +1 -0
- npdatetime_django/utils.py +131 -0
- npdatetime_django/widgets.py +168 -0
|
@@ -0,0 +1,813 @@
|
|
|
1
|
+
/* @ts-self-types="./npdatetime_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Astronomical Bikram Sambat date for JavaScript
|
|
5
|
+
*/
|
|
6
|
+
export class BsDate {
|
|
7
|
+
static __wrap(ptr) {
|
|
8
|
+
ptr = ptr >>> 0;
|
|
9
|
+
const obj = Object.create(BsDate.prototype);
|
|
10
|
+
obj.__wbg_ptr = ptr;
|
|
11
|
+
BsDateFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
__destroy_into_raw() {
|
|
15
|
+
const ptr = this.__wbg_ptr;
|
|
16
|
+
this.__wbg_ptr = 0;
|
|
17
|
+
BsDateFinalization.unregister(this);
|
|
18
|
+
return ptr;
|
|
19
|
+
}
|
|
20
|
+
free() {
|
|
21
|
+
const ptr = this.__destroy_into_raw();
|
|
22
|
+
wasm.__wbg_bsdate_free(ptr, 0);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @returns {number}
|
|
26
|
+
*/
|
|
27
|
+
get day() {
|
|
28
|
+
const ret = wasm.bsdate_day(this.__wbg_ptr);
|
|
29
|
+
return ret;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @param {number} year
|
|
33
|
+
* @param {number} month
|
|
34
|
+
* @param {number} day
|
|
35
|
+
* @returns {BsDate}
|
|
36
|
+
*/
|
|
37
|
+
static fromGregorian(year, month, day) {
|
|
38
|
+
try {
|
|
39
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
40
|
+
wasm.bsdate_fromGregorian(retptr, year, month, day);
|
|
41
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
42
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
43
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
44
|
+
if (r2) {
|
|
45
|
+
throw takeObject(r1);
|
|
46
|
+
}
|
|
47
|
+
return BsDate.__wrap(r0);
|
|
48
|
+
} finally {
|
|
49
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* @returns {number}
|
|
54
|
+
*/
|
|
55
|
+
get month() {
|
|
56
|
+
const ret = wasm.bsdate_month(this.__wbg_ptr);
|
|
57
|
+
return ret;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create a new astronomical BS date
|
|
61
|
+
* @param {number} year
|
|
62
|
+
* @param {number} month
|
|
63
|
+
* @param {number} day
|
|
64
|
+
*/
|
|
65
|
+
constructor(year, month, day) {
|
|
66
|
+
try {
|
|
67
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
68
|
+
wasm.bsdate_new(retptr, year, month, day);
|
|
69
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
70
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
71
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
72
|
+
if (r2) {
|
|
73
|
+
throw takeObject(r1);
|
|
74
|
+
}
|
|
75
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
76
|
+
BsDateFinalization.register(this, this.__wbg_ptr, this);
|
|
77
|
+
return this;
|
|
78
|
+
} finally {
|
|
79
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get Tithi for the date (Astronomical)
|
|
84
|
+
* @returns {string}
|
|
85
|
+
*/
|
|
86
|
+
tithi() {
|
|
87
|
+
let deferred2_0;
|
|
88
|
+
let deferred2_1;
|
|
89
|
+
try {
|
|
90
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
91
|
+
wasm.bsdate_tithi(retptr, this.__wbg_ptr);
|
|
92
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
93
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
94
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
95
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
96
|
+
var ptr1 = r0;
|
|
97
|
+
var len1 = r1;
|
|
98
|
+
if (r3) {
|
|
99
|
+
ptr1 = 0; len1 = 0;
|
|
100
|
+
throw takeObject(r2);
|
|
101
|
+
}
|
|
102
|
+
deferred2_0 = ptr1;
|
|
103
|
+
deferred2_1 = len1;
|
|
104
|
+
return getStringFromWasm0(ptr1, len1);
|
|
105
|
+
} finally {
|
|
106
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
107
|
+
wasm.__wbindgen_export(deferred2_0, deferred2_1, 1);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @returns {Int32Array}
|
|
112
|
+
*/
|
|
113
|
+
toGregorian() {
|
|
114
|
+
try {
|
|
115
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
116
|
+
wasm.bsdate_toGregorian(retptr, this.__wbg_ptr);
|
|
117
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
118
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
119
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
120
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
121
|
+
if (r3) {
|
|
122
|
+
throw takeObject(r2);
|
|
123
|
+
}
|
|
124
|
+
var v1 = getArrayI32FromWasm0(r0, r1).slice();
|
|
125
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
126
|
+
return v1;
|
|
127
|
+
} finally {
|
|
128
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @returns {string}
|
|
133
|
+
*/
|
|
134
|
+
toString() {
|
|
135
|
+
let deferred1_0;
|
|
136
|
+
let deferred1_1;
|
|
137
|
+
try {
|
|
138
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
139
|
+
wasm.bsdate_toString(retptr, this.__wbg_ptr);
|
|
140
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
141
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
142
|
+
deferred1_0 = r0;
|
|
143
|
+
deferred1_1 = r1;
|
|
144
|
+
return getStringFromWasm0(r0, r1);
|
|
145
|
+
} finally {
|
|
146
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
147
|
+
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* @returns {number}
|
|
152
|
+
*/
|
|
153
|
+
get year() {
|
|
154
|
+
const ret = wasm.bsdate_year(this.__wbg_ptr);
|
|
155
|
+
return ret;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (Symbol.dispose) BsDate.prototype[Symbol.dispose] = BsDate.prototype.free;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Nepali (Bikram Sambat) date for JavaScript
|
|
162
|
+
*/
|
|
163
|
+
export class NepaliDate {
|
|
164
|
+
static __wrap(ptr) {
|
|
165
|
+
ptr = ptr >>> 0;
|
|
166
|
+
const obj = Object.create(NepaliDate.prototype);
|
|
167
|
+
obj.__wbg_ptr = ptr;
|
|
168
|
+
NepaliDateFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
169
|
+
return obj;
|
|
170
|
+
}
|
|
171
|
+
__destroy_into_raw() {
|
|
172
|
+
const ptr = this.__wbg_ptr;
|
|
173
|
+
this.__wbg_ptr = 0;
|
|
174
|
+
NepaliDateFinalization.unregister(this);
|
|
175
|
+
return ptr;
|
|
176
|
+
}
|
|
177
|
+
free() {
|
|
178
|
+
const ptr = this.__destroy_into_raw();
|
|
179
|
+
wasm.__wbg_nepalidate_free(ptr, 0);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Add days to the date
|
|
183
|
+
*
|
|
184
|
+
* @param {number} days - Number of days to add (can be negative)
|
|
185
|
+
* @returns {NepaliDate} New date after adding days
|
|
186
|
+
* @param {number} days
|
|
187
|
+
* @returns {NepaliDate}
|
|
188
|
+
*/
|
|
189
|
+
addDays(days) {
|
|
190
|
+
try {
|
|
191
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
192
|
+
wasm.nepalidate_addDays(retptr, this.__wbg_ptr, days);
|
|
193
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
194
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
195
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
196
|
+
if (r2) {
|
|
197
|
+
throw takeObject(r1);
|
|
198
|
+
}
|
|
199
|
+
return NepaliDate.__wrap(r0);
|
|
200
|
+
} finally {
|
|
201
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Get the day
|
|
206
|
+
* @returns {number}
|
|
207
|
+
*/
|
|
208
|
+
get day() {
|
|
209
|
+
const ret = wasm.bsdate_day(this.__wbg_ptr);
|
|
210
|
+
return ret;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Get the fiscal quarter (1-4)
|
|
214
|
+
* @returns {number}
|
|
215
|
+
*/
|
|
216
|
+
get fiscalQuarter() {
|
|
217
|
+
const ret = wasm.nepalidate_fiscalQuarter(this.__wbg_ptr);
|
|
218
|
+
return ret;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Get the Nepali Fiscal Year (e.g., "2080/81")
|
|
222
|
+
* @returns {string}
|
|
223
|
+
*/
|
|
224
|
+
get fiscalYear() {
|
|
225
|
+
let deferred1_0;
|
|
226
|
+
let deferred1_1;
|
|
227
|
+
try {
|
|
228
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
229
|
+
wasm.nepalidate_fiscalYear(retptr, this.__wbg_ptr);
|
|
230
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
231
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
232
|
+
deferred1_0 = r0;
|
|
233
|
+
deferred1_1 = r1;
|
|
234
|
+
return getStringFromWasm0(r0, r1);
|
|
235
|
+
} finally {
|
|
236
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
237
|
+
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Format the date as a string
|
|
242
|
+
*
|
|
243
|
+
* @param {string} format - Format string (strftime-style)
|
|
244
|
+
* @returns {string} Formatted date string
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* const date = new NepaliDate(2077, 5, 19);
|
|
248
|
+
* console.log(date.format("%d %B %Y")); // "19 Bhadra 2077"
|
|
249
|
+
* @param {string} format_str
|
|
250
|
+
* @returns {string}
|
|
251
|
+
*/
|
|
252
|
+
format(format_str) {
|
|
253
|
+
let deferred2_0;
|
|
254
|
+
let deferred2_1;
|
|
255
|
+
try {
|
|
256
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
257
|
+
const ptr0 = passStringToWasm0(format_str, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
258
|
+
const len0 = WASM_VECTOR_LEN;
|
|
259
|
+
wasm.nepalidate_format(retptr, this.__wbg_ptr, ptr0, len0);
|
|
260
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
261
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
262
|
+
deferred2_0 = r0;
|
|
263
|
+
deferred2_1 = r1;
|
|
264
|
+
return getStringFromWasm0(r0, r1);
|
|
265
|
+
} finally {
|
|
266
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
267
|
+
wasm.__wbindgen_export(deferred2_0, deferred2_1, 1);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Format the date in Unicode Devanagari script
|
|
272
|
+
* @returns {string}
|
|
273
|
+
*/
|
|
274
|
+
formatUnicode() {
|
|
275
|
+
let deferred1_0;
|
|
276
|
+
let deferred1_1;
|
|
277
|
+
try {
|
|
278
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
279
|
+
wasm.nepalidate_formatUnicode(retptr, this.__wbg_ptr);
|
|
280
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
281
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
282
|
+
deferred1_0 = r0;
|
|
283
|
+
deferred1_1 = r1;
|
|
284
|
+
return getStringFromWasm0(r0, r1);
|
|
285
|
+
} finally {
|
|
286
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
287
|
+
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Create NepaliDate from Gregorian (AD) date
|
|
292
|
+
*
|
|
293
|
+
* @param {number} year - Gregorian year
|
|
294
|
+
* @param {number} month - Month (1-12)
|
|
295
|
+
* @param {number} day - Day of month
|
|
296
|
+
* @returns {NepaliDate} Converted Nepali date
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* const date = NepaliDate.fromGregorian(2020, 9, 4);
|
|
300
|
+
* console.log(date.toString()); // "2077-05-19"
|
|
301
|
+
* @param {number} year
|
|
302
|
+
* @param {number} month
|
|
303
|
+
* @param {number} day
|
|
304
|
+
* @returns {NepaliDate}
|
|
305
|
+
*/
|
|
306
|
+
static fromGregorian(year, month, day) {
|
|
307
|
+
try {
|
|
308
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
309
|
+
wasm.nepalidate_fromGregorian(retptr, year, month, day);
|
|
310
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
311
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
312
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
313
|
+
if (r2) {
|
|
314
|
+
throw takeObject(r1);
|
|
315
|
+
}
|
|
316
|
+
return NepaliDate.__wrap(r0);
|
|
317
|
+
} finally {
|
|
318
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Create NepaliDate from an ordinal
|
|
323
|
+
* @param {number} ordinal
|
|
324
|
+
* @returns {NepaliDate}
|
|
325
|
+
*/
|
|
326
|
+
static fromOrdinal(ordinal) {
|
|
327
|
+
try {
|
|
328
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
329
|
+
wasm.nepalidate_fromOrdinal(retptr, ordinal);
|
|
330
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
331
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
332
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
333
|
+
if (r2) {
|
|
334
|
+
throw takeObject(r1);
|
|
335
|
+
}
|
|
336
|
+
return NepaliDate.__wrap(r0);
|
|
337
|
+
} finally {
|
|
338
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Get the month (1-12)
|
|
343
|
+
* @returns {number}
|
|
344
|
+
*/
|
|
345
|
+
get month() {
|
|
346
|
+
const ret = wasm.bsdate_month(this.__wbg_ptr);
|
|
347
|
+
return ret;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Generate a visual month calendar
|
|
351
|
+
* @returns {string}
|
|
352
|
+
*/
|
|
353
|
+
monthCalendar() {
|
|
354
|
+
let deferred1_0;
|
|
355
|
+
let deferred1_1;
|
|
356
|
+
try {
|
|
357
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
358
|
+
wasm.nepalidate_monthCalendar(retptr, this.__wbg_ptr);
|
|
359
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
360
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
361
|
+
deferred1_0 = r0;
|
|
362
|
+
deferred1_1 = r1;
|
|
363
|
+
return getStringFromWasm0(r0, r1);
|
|
364
|
+
} finally {
|
|
365
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
366
|
+
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Create a new Nepali date
|
|
371
|
+
*
|
|
372
|
+
* @param {number} year - Bikram Sambat year
|
|
373
|
+
* @param {number} month - Month (1-12)
|
|
374
|
+
* @param {number} day - Day of month
|
|
375
|
+
* @returns {NepaliDate} New NepaliDate instance
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* const date = new NepaliDate(2077, 5, 19);
|
|
379
|
+
* console.log(date.toString()); // "2077-05-19"
|
|
380
|
+
* @param {number} year
|
|
381
|
+
* @param {number} month
|
|
382
|
+
* @param {number} day
|
|
383
|
+
*/
|
|
384
|
+
constructor(year, month, day) {
|
|
385
|
+
try {
|
|
386
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
387
|
+
wasm.nepalidate_new(retptr, year, month, day);
|
|
388
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
389
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
390
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
391
|
+
if (r2) {
|
|
392
|
+
throw takeObject(r1);
|
|
393
|
+
}
|
|
394
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
395
|
+
NepaliDateFinalization.register(this, this.__wbg_ptr, this);
|
|
396
|
+
return this;
|
|
397
|
+
} finally {
|
|
398
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Get Tithi for the date (Astronomical)
|
|
403
|
+
*
|
|
404
|
+
* @returns {string} Tithi name (e.g., "Shukla Pratipada")
|
|
405
|
+
* @returns {string}
|
|
406
|
+
*/
|
|
407
|
+
tithi() {
|
|
408
|
+
let deferred2_0;
|
|
409
|
+
let deferred2_1;
|
|
410
|
+
try {
|
|
411
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
412
|
+
wasm.nepalidate_tithi(retptr, this.__wbg_ptr);
|
|
413
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
414
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
415
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
416
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
417
|
+
var ptr1 = r0;
|
|
418
|
+
var len1 = r1;
|
|
419
|
+
if (r3) {
|
|
420
|
+
ptr1 = 0; len1 = 0;
|
|
421
|
+
throw takeObject(r2);
|
|
422
|
+
}
|
|
423
|
+
deferred2_0 = ptr1;
|
|
424
|
+
deferred2_1 = len1;
|
|
425
|
+
return getStringFromWasm0(ptr1, len1);
|
|
426
|
+
} finally {
|
|
427
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
428
|
+
wasm.__wbindgen_export(deferred2_0, deferred2_1, 1);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Convert to Gregorian (AD) date
|
|
433
|
+
*
|
|
434
|
+
* @returns {Array<number>} [year, month, day]
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* const date = new NepaliDate(2077, 5, 19);
|
|
438
|
+
* const [year, month, day] = date.toGregorian();
|
|
439
|
+
* console.log(`${year}-${month}-${day}`); // "2020-9-4"
|
|
440
|
+
* @returns {Int32Array}
|
|
441
|
+
*/
|
|
442
|
+
toGregorian() {
|
|
443
|
+
try {
|
|
444
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
445
|
+
wasm.nepalidate_toGregorian(retptr, this.__wbg_ptr);
|
|
446
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
447
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
448
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
449
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
450
|
+
if (r3) {
|
|
451
|
+
throw takeObject(r2);
|
|
452
|
+
}
|
|
453
|
+
var v1 = getArrayI32FromWasm0(r0, r1).slice();
|
|
454
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
455
|
+
return v1;
|
|
456
|
+
} finally {
|
|
457
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Get the ordinal representation of the date (days since 1975-01-01 BS)
|
|
462
|
+
* @returns {number}
|
|
463
|
+
*/
|
|
464
|
+
toOrdinal() {
|
|
465
|
+
const ret = wasm.nepalidate_toOrdinal(this.__wbg_ptr);
|
|
466
|
+
return ret;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* String representation
|
|
470
|
+
* @returns {string}
|
|
471
|
+
*/
|
|
472
|
+
toString() {
|
|
473
|
+
let deferred1_0;
|
|
474
|
+
let deferred1_1;
|
|
475
|
+
try {
|
|
476
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
477
|
+
wasm.nepalidate_toString(retptr, this.__wbg_ptr);
|
|
478
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
479
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
480
|
+
deferred1_0 = r0;
|
|
481
|
+
deferred1_1 = r1;
|
|
482
|
+
return getStringFromWasm0(r0, r1);
|
|
483
|
+
} finally {
|
|
484
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
485
|
+
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Get today's Nepali date
|
|
490
|
+
*
|
|
491
|
+
* @returns {NepaliDate} Today's date in BS
|
|
492
|
+
* @returns {NepaliDate}
|
|
493
|
+
*/
|
|
494
|
+
static today() {
|
|
495
|
+
try {
|
|
496
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
497
|
+
wasm.nepalidate_today(retptr);
|
|
498
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
499
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
500
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
501
|
+
if (r2) {
|
|
502
|
+
throw takeObject(r1);
|
|
503
|
+
}
|
|
504
|
+
return NepaliDate.__wrap(r0);
|
|
505
|
+
} finally {
|
|
506
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Get the year
|
|
511
|
+
* @returns {number}
|
|
512
|
+
*/
|
|
513
|
+
get year() {
|
|
514
|
+
const ret = wasm.bsdate_year(this.__wbg_ptr);
|
|
515
|
+
return ret;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
if (Symbol.dispose) NepaliDate.prototype[Symbol.dispose] = NepaliDate.prototype.free;
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Initialize WASM module
|
|
522
|
+
*/
|
|
523
|
+
export function init() {
|
|
524
|
+
wasm.init();
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function __wbg_get_imports() {
|
|
528
|
+
const import0 = {
|
|
529
|
+
__proto__: null,
|
|
530
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
531
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
532
|
+
},
|
|
533
|
+
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
534
|
+
let deferred0_0;
|
|
535
|
+
let deferred0_1;
|
|
536
|
+
try {
|
|
537
|
+
deferred0_0 = arg0;
|
|
538
|
+
deferred0_1 = arg1;
|
|
539
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
540
|
+
} finally {
|
|
541
|
+
wasm.__wbindgen_export(deferred0_0, deferred0_1, 1);
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
__wbg_getDate_db46eca87d2b4907: function(arg0) {
|
|
545
|
+
const ret = getObject(arg0).getDate();
|
|
546
|
+
return ret;
|
|
547
|
+
},
|
|
548
|
+
__wbg_getFullYear_30ddf266b7612036: function(arg0) {
|
|
549
|
+
const ret = getObject(arg0).getFullYear();
|
|
550
|
+
return ret;
|
|
551
|
+
},
|
|
552
|
+
__wbg_getMonth_4af888e76b42bb51: function(arg0) {
|
|
553
|
+
const ret = getObject(arg0).getMonth();
|
|
554
|
+
return ret;
|
|
555
|
+
},
|
|
556
|
+
__wbg_new_0_73afc35eb544e539: function() {
|
|
557
|
+
const ret = new Date();
|
|
558
|
+
return addHeapObject(ret);
|
|
559
|
+
},
|
|
560
|
+
__wbg_new_8a6f238a6ece86ea: function() {
|
|
561
|
+
const ret = new Error();
|
|
562
|
+
return addHeapObject(ret);
|
|
563
|
+
},
|
|
564
|
+
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
565
|
+
const ret = getObject(arg1).stack;
|
|
566
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
567
|
+
const len1 = WASM_VECTOR_LEN;
|
|
568
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
569
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
570
|
+
},
|
|
571
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
572
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
573
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
574
|
+
return addHeapObject(ret);
|
|
575
|
+
},
|
|
576
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
577
|
+
takeObject(arg0);
|
|
578
|
+
},
|
|
579
|
+
};
|
|
580
|
+
return {
|
|
581
|
+
__proto__: null,
|
|
582
|
+
"./npdatetime_wasm_bg.js": import0,
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
const BsDateFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
587
|
+
? { register: () => {}, unregister: () => {} }
|
|
588
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_bsdate_free(ptr >>> 0, 1));
|
|
589
|
+
const NepaliDateFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
590
|
+
? { register: () => {}, unregister: () => {} }
|
|
591
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_nepalidate_free(ptr >>> 0, 1));
|
|
592
|
+
|
|
593
|
+
function addHeapObject(obj) {
|
|
594
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
595
|
+
const idx = heap_next;
|
|
596
|
+
heap_next = heap[idx];
|
|
597
|
+
|
|
598
|
+
heap[idx] = obj;
|
|
599
|
+
return idx;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function dropObject(idx) {
|
|
603
|
+
if (idx < 132) return;
|
|
604
|
+
heap[idx] = heap_next;
|
|
605
|
+
heap_next = idx;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
function getArrayI32FromWasm0(ptr, len) {
|
|
609
|
+
ptr = ptr >>> 0;
|
|
610
|
+
return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
let cachedDataViewMemory0 = null;
|
|
614
|
+
function getDataViewMemory0() {
|
|
615
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
616
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
617
|
+
}
|
|
618
|
+
return cachedDataViewMemory0;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
let cachedInt32ArrayMemory0 = null;
|
|
622
|
+
function getInt32ArrayMemory0() {
|
|
623
|
+
if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
|
|
624
|
+
cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
|
|
625
|
+
}
|
|
626
|
+
return cachedInt32ArrayMemory0;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function getStringFromWasm0(ptr, len) {
|
|
630
|
+
ptr = ptr >>> 0;
|
|
631
|
+
return decodeText(ptr, len);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
let cachedUint8ArrayMemory0 = null;
|
|
635
|
+
function getUint8ArrayMemory0() {
|
|
636
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
637
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
638
|
+
}
|
|
639
|
+
return cachedUint8ArrayMemory0;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function getObject(idx) { return heap[idx]; }
|
|
643
|
+
|
|
644
|
+
let heap = new Array(128).fill(undefined);
|
|
645
|
+
heap.push(undefined, null, true, false);
|
|
646
|
+
|
|
647
|
+
let heap_next = heap.length;
|
|
648
|
+
|
|
649
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
650
|
+
if (realloc === undefined) {
|
|
651
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
652
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
653
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
654
|
+
WASM_VECTOR_LEN = buf.length;
|
|
655
|
+
return ptr;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
let len = arg.length;
|
|
659
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
660
|
+
|
|
661
|
+
const mem = getUint8ArrayMemory0();
|
|
662
|
+
|
|
663
|
+
let offset = 0;
|
|
664
|
+
|
|
665
|
+
for (; offset < len; offset++) {
|
|
666
|
+
const code = arg.charCodeAt(offset);
|
|
667
|
+
if (code > 0x7F) break;
|
|
668
|
+
mem[ptr + offset] = code;
|
|
669
|
+
}
|
|
670
|
+
if (offset !== len) {
|
|
671
|
+
if (offset !== 0) {
|
|
672
|
+
arg = arg.slice(offset);
|
|
673
|
+
}
|
|
674
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
675
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
676
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
677
|
+
|
|
678
|
+
offset += ret.written;
|
|
679
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
WASM_VECTOR_LEN = offset;
|
|
683
|
+
return ptr;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function takeObject(idx) {
|
|
687
|
+
const ret = getObject(idx);
|
|
688
|
+
dropObject(idx);
|
|
689
|
+
return ret;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
693
|
+
cachedTextDecoder.decode();
|
|
694
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
695
|
+
let numBytesDecoded = 0;
|
|
696
|
+
function decodeText(ptr, len) {
|
|
697
|
+
numBytesDecoded += len;
|
|
698
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
699
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
700
|
+
cachedTextDecoder.decode();
|
|
701
|
+
numBytesDecoded = len;
|
|
702
|
+
}
|
|
703
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
const cachedTextEncoder = new TextEncoder();
|
|
707
|
+
|
|
708
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
709
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
710
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
711
|
+
view.set(buf);
|
|
712
|
+
return {
|
|
713
|
+
read: arg.length,
|
|
714
|
+
written: buf.length
|
|
715
|
+
};
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
let WASM_VECTOR_LEN = 0;
|
|
720
|
+
|
|
721
|
+
let wasmModule, wasm;
|
|
722
|
+
function __wbg_finalize_init(instance, module) {
|
|
723
|
+
wasm = instance.exports;
|
|
724
|
+
wasmModule = module;
|
|
725
|
+
cachedDataViewMemory0 = null;
|
|
726
|
+
cachedInt32ArrayMemory0 = null;
|
|
727
|
+
cachedUint8ArrayMemory0 = null;
|
|
728
|
+
wasm.__wbindgen_start();
|
|
729
|
+
return wasm;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
async function __wbg_load(module, imports) {
|
|
733
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
734
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
735
|
+
try {
|
|
736
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
737
|
+
} catch (e) {
|
|
738
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
739
|
+
|
|
740
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
741
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
742
|
+
|
|
743
|
+
} else { throw e; }
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
const bytes = await module.arrayBuffer();
|
|
748
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
749
|
+
} else {
|
|
750
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
751
|
+
|
|
752
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
753
|
+
return { instance, module };
|
|
754
|
+
} else {
|
|
755
|
+
return instance;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
function expectedResponseType(type) {
|
|
760
|
+
switch (type) {
|
|
761
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
762
|
+
}
|
|
763
|
+
return false;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
function initSync(module) {
|
|
768
|
+
if (wasm !== undefined) return wasm;
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
if (module !== undefined) {
|
|
772
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
773
|
+
({module} = module)
|
|
774
|
+
} else {
|
|
775
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
const imports = __wbg_get_imports();
|
|
780
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
781
|
+
module = new WebAssembly.Module(module);
|
|
782
|
+
}
|
|
783
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
784
|
+
return __wbg_finalize_init(instance, module);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
async function __wbg_init(module_or_path) {
|
|
788
|
+
if (wasm !== undefined) return wasm;
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
if (module_or_path !== undefined) {
|
|
792
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
793
|
+
({module_or_path} = module_or_path)
|
|
794
|
+
} else {
|
|
795
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
if (module_or_path === undefined) {
|
|
800
|
+
module_or_path = new URL('npdatetime_wasm_bg.wasm', import.meta.url);
|
|
801
|
+
}
|
|
802
|
+
const imports = __wbg_get_imports();
|
|
803
|
+
|
|
804
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
805
|
+
module_or_path = fetch(module_or_path);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
809
|
+
|
|
810
|
+
return __wbg_finalize_init(instance, module);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
export { initSync, __wbg_init as default };
|