@@ -8,7 +8,12 @@ import {
88 nepaliDateToString ,
99} from './format'
1010
11- import { parse , parseFormat , parseEnglishDateFormat } from './parse'
11+ import {
12+ simpleParse ,
13+ parseFormat ,
14+ parseEnglishDateFormat ,
15+ parseNepaliFormat ,
16+ } from './parse'
1217import { getDate , getNepalDateAndTime } from './utils'
1318import { validateTime } from './validators'
1419
@@ -170,7 +175,7 @@ class NepaliDate {
170175 }
171176
172177 private parseFromString ( value : string ) {
173- const parsedResult = parse ( value )
178+ const parsedResult = simpleParse ( value )
174179 this . set (
175180 parsedResult [ 0 ] , // Year
176181 parsedResult [ 1 ] , // Month
@@ -250,7 +255,7 @@ class NepaliDate {
250255 *
251256 * @returns {Date } The equivalent JavaScript Date object.
252257 */
253- getDateObject ( ) {
258+ getDateObject ( ) : Date {
254259 return this . timestamp
255260 }
256261
@@ -624,8 +629,27 @@ class NepaliDate {
624629 }
625630
626631 /**
627- * Creates a NepaliDate instance by parsing a provided English Date and Time string
628- * with the given format.
632+ * Parses a Nepali date-time string in Devanagari form according to the
633+ * specified format and returns a `NepaliDate` instance.
634+ *
635+ * @param dateStringNe - The Nepali Date and time string in Devanagari.
636+ * @param format - The format of the provided date-time string.
637+ * @example
638+ * const dateStringNe = '२०८०/०८/१२ १४-०५-२३.७८९'
639+ * const format = 'YYYY/MM/DD HH-mm-ss.SSS'
640+ * const nepaliDate = NepaliDate.parseNepaliFormat(dateStringNe, format)
641+ */
642+ static parseNepaliFormat ( dateStringNe : string , format : string ) : NepaliDate {
643+ const [ year , month0 , day , hour , minute , second , ms ] = parseNepaliFormat (
644+ dateStringNe ,
645+ format
646+ )
647+ return new NepaliDate ( year , month0 , day , hour , minute , second , ms )
648+ }
649+
650+ /**
651+ * Parses an English date-time string according to the specified format
652+ * and returns a `NepaliDate` instance.
629653 *
630654 * @param dateString - The English Date and time string.
631655 * @param format - The format of the provided date-time string.
0 commit comments