ParseDate

This function returns parsed date in object format {year, month, day}.

new ParseDate(dateString: string): object
Parameters
dateString (string) any date string
Returns
object: returns date in object and its format.
Example
NepaliFunctions.ParseDate("2000-01-01")
// returns { parsedDate: { year: 2000, month: 1, day: 1}, parsedFormat: "YYYY-MM-DD" }

ConvertToDateObject

This function returns date in object format {year, month, day}.

new ConvertToDateObject(dateString: string, dateFormat: string): object
Parameters
dateString (string) any date string
dateFormat (string) source format
Returns
object: returns date in object format.
Example
NepaliFunctions.ConvertToDateObject("2000-01-01", "YYYY-MM-DD")
// returns { year: 2000, month: 1, day: 1}
NepaliFunctions.ConvertToDateObject("2000/01/01", "YYYY/MM/DD")
// returns { year: 2000, month: 1, day: 1}
NepaliFunctions.ConvertToDateObject("01-01-2000", "MM-DD-YYYY")
// returns { year: 2000, month: 1, day: 1}
NepaliFunctions.ConvertToDateObject("01/01/2000", "MM/DD/YYYY")
// returns { year: 2000, month: 1, day: 1}

ConvertDateFormat

This function returns date in target format.

new ConvertDateFormat(dateObj: string, returnFormat: string): string
Parameters
dateObj (string) any date object
returnFormat (string) target format
Returns
string: returns date in target format.
Example
NepaliFunctions.ConvertDateFormat({year: 2000, month: 1, day: 1}, "YYYY-MM-DD")
// Returns "2001-01-01"
NepaliFunctions.ConvertDateFormat({year: 2000, month: 1, day: 1}, "YYYY/MM/DD")
// Returns "2001/01/01"
NepaliFunctions.ConvertDateFormat({year: 2000, month: 1, day: 1}, "MM-DD-YYYY")
// Returns "01-01-2001"
NepaliFunctions.ConvertDateFormat({year: 2000, month: 1, day: 1}, "MM/DD/YYYY")
// Returns "01/01/2001"

AD2BS

This function converts AD date object to BS date object.

new AD2BS(adDate: (object | string), sourceDateFormat: string, returnDateFormat: string): string
Parameters
adDate ((object | string)) any AD date object or AD date string
sourceDateFormat (string) any available date formats and required only if adDate is string
returnDateFormat (string) any available date formats
Returns
string: converts AD date object to BS date object.
Example
NepaliFunctions.AD2BS({year: 2001, month: 6, day: 1})
// returns {year: 2058, month: 2, day: 19}
NepaliFunctions.AD2BS({year: 2008, month: 5, day: 28})
// returns {year: 2065, month: 2, day: 15}
NepaliFunctions.AD2BS("2008-05-28")
// returns 2065-02-15
NepaliFunctions.AD2BS("2008-05-28", "YYYY-MM-DD")
// returns 2065-02-15
NepaliFunctions.AD2BS("2008-05-28", "YYYY-MM-DD", "YYYY/MM/DD")
// returns 2065/02/15

BS2AD

This function converts BS date object to AD date object.

new BS2AD(bsDate: (object | string), sourceDateFormat: string, returnDateFormat: string): string
Parameters
bsDate ((object | string)) any BS date object or BS date string
sourceDateFormat (string) any available date formats and required only if bsDate is string
returnDateFormat (string) any available date formats
Returns
string: converts BS date object to AD date object.
Example
NepaliFunctions.BS2AD({year: 2058, month: 2, day: 19})
// returns {year: 2001, month: 6, day: 1}
NepaliFunctions.BS2AD({year: 2065, month: 2, day: 15})
// returns {year: 2008, month: 5, day: 28}
NepaliFunctions.BS2AD("2065-02-15")
// returns 2008-05-28
NepaliFunctions.BS2AD("2065-02-15", "YYYY-MM-DD")
// returns 2008-05-28
NepaliFunctions.BS2AD("2065-02-15", "YYYY-MM-DD", "YYYY/MM/DD")
// returns 2008/05/28

ValidateBsDate

This function checks the validity of the BS date.

new ValidateBsDate(bsDate: (object | string), dateFormat: string): boolean
Parameters
bsDate ((object | string)) any BS date object or BS date string
dateFormat (string) any available date formats and required only if bsDate is string
Returns
boolean: the validity of the BS date object.
Example
NepaliFunctions.ValidateBsDate({year: 2000, month: 2, day: 30})
// Returns true
NepaliFunctions.ValidateBsDate({year: 2064, month: 4, day: 32})
// Returns true
NepaliFunctions.ValidateBsDate({year: 2000, month: 13, day: 30})
// Returns false
NepaliFunctions.ValidateBsDate({year: 2000, month: 12, day: 32})
// Returns false
NepaliFunctions.ValidateBsDate("2078-01-05")
// Returns true
NepaliFunctions.ValidateBsDate("2078-01-32")
// Returns false
NepaliFunctions.ValidateBsDate("2078/01/30")
// Returns false
NepaliFunctions.ValidateBsDate("2078/01/30", "YYYY/MM/DD")
// Returns true

GetCurrentAdDate

This function returns the current AD date object.

new GetCurrentAdDate(dateFormat: string): (object | string)
Parameters
dateFormat (string) any available date formats.
Returns
(object | string): the current AD date object or string if date format is provided.
Example
NepaliFunctions.GetCurrentAdDate()
// Returns {year: 2020, month: 1, day: 1}
// if today"s date is 1st January 2020
NepaliFunctions.GetCurrentAdDate('YYYY-MM-DD')
// Returns 2020-01-01
// if today"s date is 1st January 2020

GetCurrentAdYear

This function returns the current AD year.

new GetCurrentAdYear(): number
Returns
number: the current AD year.
Example
NepaliFunctions.GetCurrentAdYear()
// Returns 2020
// if today"s date is 1st January 2020

GetCurrentAdMonth

This function returns the current AD month.

new GetCurrentAdMonth(): number
Returns
number: the current AD month.
Example
NepaliFunctions.GetCurrentAdMonth()
// Returns 1
// if today"s date is 1st January 2020

GetCurrentAdDay

This function returns the current AD day.

new GetCurrentAdDay(): number
Returns
number: the current AD day.
Example
NepaliFunctions.GetCurrentAdDay()
// Returns 1
// if today"s date is 1st January 2020

GetCurrentBsDate

This function returns the current BS date object.

new GetCurrentBsDate(dateFormat: string): (object | string)
Parameters
dateFormat (string) any available date formats
Returns
(object | string): the current BS date object or string if date format is provided.
Example
NepaliFunctions.GetCurrentBsDate()
// Returns {year: 2076, month: 9, day: 1}
// if today"s date is 1st Poush 2076
NepaliFunctions.GetCurrentBsDate('YYYY-MM-DD')
// Returns {year: 2076, month: 9, day: 1}
// if today"s date is 1st Poush 2076

GetCurrentBsYear

This function returns the current BS year.

new GetCurrentBsYear(): number
Returns
number: the current BS year.
Example
NepaliFunctions.GetCurrentBsYear()
// Returns 2076
// if today"s date is 1st Poush 2076

GetCurrentBsMonth

This function returns the current BS month.

new GetCurrentBsMonth(): number
Returns
number: the current BS month.
Example
NepaliFunctions.GetCurrentBsMonth()
// Returns 9
// if today"s date is 1st Poush 2076

GetCurrentBsDay

This function returns the current BS day.

new GetCurrentBsDay(): number
Returns
number: the current BS day.
Example
NepaliFunctions.GetCurrentBsDay()
// Returns 1
// if today"s date is 1st Poush 2076

GetAdMonths

This function returns the AD months.

new GetAdMonths(): array
Returns
array: the AD months.
Example
NepaliFunctions.GetAdMonths()
// Returns ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

GetAdMonth

This function returns the AD month.

new GetAdMonth(number: number): string
Parameters
number (number) any number
Returns
string: the AD month.
Example
NepaliFunctions.GetAdMonth(0)
// Returns January
NepaliFunctions.GetAdMonth(5)
// Returns June
NepaliFunctions.GetAdMonth(11)
// Returns December
NepaliFunctions.GetAdMonth(-1)
// Returns null
NepaliFunctions.GetAdMonth(12)
// Returns null

GetBsMonths

This function returns the BS months in English.

new GetBsMonths(): array
Returns
array: the BS months.
Example
NepaliFunctions.GetBsMonths()
// Returns  ["Baisakh", "Jestha", "Ashar", "Shrawan", "Bhadra", "Ashoj", "Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra"]

GetBsMonth

This function returns the BS month in English.

new GetBsMonth(number: number): string
Parameters
number (number) any number
Returns
string: the BS month.
Example
NepaliFunctions.GetBsMonth(0)
// Returns Baisakh
NepaliFunctions.GetBsMonth(5)
// Returns Ashoj
NepaliFunctions.GetBsMonth(11)
// Returns Chaitra
NepaliFunctions.GetBsMonth(-1)
// Returns null
NepaliFunctions.GetBsMonth(12)
// Returns null

GetBsMonthsInUnicode

This function returns the BS months.

new GetBsMonthsInUnicode(): array
Returns
array: the BS months.
Example
NepaliFunctions.GetBsMonthsInUnicode()
// Returns ["बैशाख", "जेठ", "अषाढ", "श्रावण", "भाद्र", "आश्विन", "कार्तिक", "मङ्सिर", "पौष", "माघ", "फाल्गुन", "चैत्र"]

GetBsMonthInUnicode

This function returns the BS month in unicode.

new GetBsMonthInUnicode(number: number): string
Parameters
number (number) any number
Returns
string: the BS month in unicode.
Example
NepaliFunctions.GetBsMonthInUnicode(0)
// Returns बैशाख
NepaliFunctions.GetBsMonthInUnicode(5)
// Returns आश्विन
NepaliFunctions.GetBsMonthInUnicode(11)
// Returns चैत्र
NepaliFunctions.GetBsMonthInUnicode(-1)
// Returns null
NepaliFunctions.GetBsMonthInUnicode(12)
// Returns null

GetBsDaysUnicode

This function returns the BS days in unicode.

new GetBsDaysUnicode(): array
Returns
array: the BS days in unicode.
Example
NepaliFunctions.GetBsDaysUnicode()
// Returns ["आइतवार", "सोमवार", "मङ्गलवार", "बुधवार", "बिहिवार", "शुक्रवार", "शनिवार"]

GetBsDayUnicode

This function returns the BS day in unicode.

new GetBsDayUnicode(number: number): string
Parameters
number (number) any number
Returns
string: the BS day in unicode.
Example
NepaliFunctions.GetBsDayUnicode(0)
// Returns आइतवार
NepaliFunctions.GetBsDayUnicode(4)
// Returns बिहिवार
NepaliFunctions.GetBsDayUnicode(7)
// Returns null

GetBsDaysUnicodeShort

This function returns the BS days in short.

new GetBsDaysUnicodeShort(): array
Returns
array: the BS days in short.
Example
NepaliFunctions.GetBsDaysUnicodeShort()
// Returns ["आ", "सो", "मं", "बु", "बि", "शु", "श"]

GetBsDayUnicodeShort

This function returns the BS day in unicode.

new GetBsDayUnicodeShort(number: number): string
Parameters
number (number) any number
Returns
string: the BS day in unicode.
Example
NepaliFunctions.GetBsDayUnicodeShort(0)
// Returns आ
NepaliFunctions.GetBsDayUnicodeShort(4)
// Returns बि
NepaliFunctions.GetBsDayUnicodeShort(7)
// Returns null

GetAdDays

This function returns the AD days.

new GetAdDays(): array
Returns
array: the AD days.
Example
NepaliFunctions.GetAdDays()
// Returns ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

GetAdDay

This function returns the AD day.

new GetAdDay(number: number): string
Parameters
number (number) any number
Returns
string: the AD day.
Example
NepaliFunctions.GetAdDay(0)
// Returns Sunday
NepaliFunctions.GetAdDay(5)
// Returns Friday
NepaliFunctions.GetAdDay(7)
// Returns null

GetAdDaysShort

This function returns the AD days Short.

new GetAdDaysShort(): array
Returns
array: the AD days short.
Example
NepaliFunctions.GetAdDaysShort()
// Returns ["S", "M", "T", "W", "T", "F", "S"]

GetAdDayShort

This function returns the AD day.

new GetAdDayShort(number: number): string
Parameters
number (number) any number
Returns
string: the AD day.
Example
NepaliFunctions.GetAdDaysShort(0)
// Returns S
NepaliFunctions.GetAdDaysShort(5)
// Returns F
NepaliFunctions.GetAdDaysShort(7)
// Returns null

GetBsFullDate

This function returns the full BS date.

new GetBsFullDate(bsDate: (object | string), unicodeFlag: boolean, dateFormat: string): string
Parameters
bsDate ((object | string)) any date object or date string
unicodeFlag (boolean) true or false
dateFormat (string) any available date formats and required only if bsDate is string
Returns
string: the full BS date.
Example
NepaliFunctions.GetBsFullDate({year: 2075, month: 3, day: 15}, false)
// Returns 15 Ashar 2075
NepaliFunctions.GetBsFullDate({year: 2075, month: 5, day: 2}, false)
// Returns 2 Bhadra 2075
NepaliFunctions.GetBsFullDate("2075-03-15", false, "YYYY-MM-DD")
// Returns 2 Bhadra 2075
NepaliFunctions.GetBsFullDate({year: 2075, month: 3, day: 15}, true)
// Returns १५ अषाढ २०७५
NepaliFunctions.GetBsFullDate({year: 2075, month: 5, day: 2}, true)
// Returns २ भाद्र २०७५
NepaliFunctions.GetBsFullDate("2075-03-15", true, "YYYY-MM-DD")
// Returns २ भाद्र २०७५

GetAdFullDate

This function returns the full AD date.

new GetAdFullDate(adDate: (object | string), dateFormat: string): string
Parameters
adDate ((object | string)) any date object or date string
dateFormat (string) any available date formats and required only if adDate is string
Returns
string: the full AD date.
Example
NepaliFunctions.GetAdFullDate({year: 2001, month: 3, day: 15})
// Returns 15 March 2001
NepaliFunctions.GetAdFullDate({year: 2003, month: 5, day: 2})
// Returns 2 May 2003
NepaliFunctions.GetAdFullDate("2003/05/02", "YYYY/MM/DD")
// Returns 2 May 2003

GetAdFullDay

This function returns the day for the given AD date object.

new GetAdFullDay(adDate: (object | string), dateFormat: string): string
Parameters
adDate ((object | string)) any date object or date string
dateFormat (string) any available date formats and required only if adDate is string
Returns
string: the day.
Example
NepaliFunctions.GetAdFullDay({year: 2001, month: 3, day: 15})
// Returns Thursday
NepaliFunctions.GetAdFullDay({year: 2003, month: 5, day: 2})
// Returns Friday
NepaliFunctions.GetAdFullDay('2003-05-02', 'YYYY-MM-DD')
// Returns Friday

GetBsFullDay

This function returns the day for the given BS date object or date string.

new GetBsFullDay(bsDate: (object | string), dateFormat: string): string
Parameters
bsDate ((object | string)) any date object or date string
dateFormat (string) any available date formats and required only if bsDate is string
Returns
string: the day.
Example
NepaliFunctions.GetBsFullDay({year: 2045, month: 3, day: 15})
// Returns Wednesday
NepaliFunctions.GetBsFullDay({year: 2077, month: 5, day: 2})
// Returns Tuesday

GetBsFullDayInUnicode

This function returns the day for the given BS date object or date string.

new GetBsFullDayInUnicode(bsDate: (object | string), dateFormat: string): string
Parameters
bsDate ((object | string)) any date object or date string
dateFormat (string) any available date formats and required only if bsDate is string
Returns
string: the day.
Example
NepaliFunctions.GetBsFullDayInUnicode({year: 2045, month: 3, day: 15})
// Returns बुधवार
NepaliFunctions.GetBsFullDayInUnicode({year: 2077, month: 5, day: 2})
// Returns मङ्गलवार
NepaliFunctions.GetBsFullDayInUnicode('2077-05-02', 'YYYY-MM-DD')
// Returns मङ्गलवार

BsAddDays

This function returns the BS date object after adding the number of days.

new BsAddDays(bsDate: (object | string), noOfDays: number, dateFormat: string): object
Parameters
bsDate ((object | string)) any date object or date string
noOfDays (number) any number
dateFormat (string) any available date formats and required only if bsDate is string
Returns
object: the BS date object after adding the number of days.
Example
NepaliFunctions.BsAddDays({year: 2001, month: 3, day: 15}, 2)
// Returns {year: 2001, month: 3, day: 17}
NepaliFunctions.BsAddDays({year: 2003, month: 5, day: 2}, 90)
// Returns {year: 2003, month: 8, day: 1}
NepaliFunctions.BsAddDays('2003-05-02', 90, 'YYYY-MM-DD')
// '2003-08-01'

AdDatesDiff

This function returns that number of days between the two AD dates objects.

new AdDatesDiff(startDate: (object | string), endDate: (object | string), dateFormat: string): number
Parameters
startDate ((object | string)) any AD date object or date string
endDate ((object | string)) any AD date object or date string
dateFormat (string) any available date formats and required only if startDate or endDate is string
Returns
number: that number of days between the two AD dates.
Example
NepaliFunctions.AdDatesDiff({year: 2001, month: 3, day: 15}, {year: 2001, month: 3, day: 17})
// Returns 2
NepaliFunctions.AdDatesDiff({year: 2003, month: 5, day: 2}, {year: 2003, month: 8, day: 1})
// Returns 91
NepaliFunctions.AdDatesDiff('2003-05-02', '2003-08-01')
// Returns 91
NepaliFunctions.AdDatesDiff('2003-05-02', '2003-08-01', 'YYYY-MM-DD')
// Returns 91

BsDatesDiff

This function returns that number of days between the two BS dates.

new BsDatesDiff(startDate: (object | string), endDate: (object | string), dateFormat: string): number
Parameters
startDate ((object | string)) any BS date object or date string
endDate ((object | string)) any BS date object or date string
dateFormat (string) any available date formats and required only if startDate or endDate is string
Returns
number: that number of days between the two BS dates.
Example
NepaliFunctions.BsDatesDiff({year: 2001, month: 3, day: 15}, {year: 2001, month: 3, day: 17})
// Returns 2
NepaliFunctions.BsDatesDiff({year: 2003, month: 5, day: 2}, {year: 2003, month: 8, day: 1})
// Returns 90
NepaliFunctions.BsDatesDiff('2003-05-02', '2003-08-01', 'YYYY-MM-DD')
// Returns 90

GetDaysInAdMonth

This function returns the number of days in the given AD year and month.

new GetDaysInAdMonth(year: number, month: number): number
Parameters
year (number) any number
month (number) any number
Returns
number: that number of days in the given AD year and month.
Example
NepaliFunctions.GetDaysInAdMonth(2015, 2)
// Returns 28
NepaliFunctions.GetDaysInAdMonth(2020, 1)
// Returns 31

GetDaysInBsMonth

This function returns the number of days in the given BS year and month.

new GetDaysInBsMonth(year: number, month: number): number
Parameters
year (number) any number
month (number) any number
Returns
number: that number of days in the given BS year and month.
Example
NepaliFunctions.GetDaysInBsMonth(2015, 2)
// Returns 32
NepaliFunctions.GetDaysInBsMonth(2020, 1)
// Returns 31

CompareBsDates

This function returns true if date is greater

new CompareBsDates(date1: (object | string), date2: (object | string), dateFormat: string): boolean
Parameters
date1 ((object | string)) first date object or date string
date2 ((object | string)) second date object or date string
dateFormat (string) any available date formats and required only if startDate or endDate is string
Returns
boolean: true if date1 is greater than date2
Example
NepaliFunctions.CompareBsDates({year: 2076, month: 2, day: 1}, {year: 2076, month: 1, day: 1})
// Returns true
NepaliFunctions.CompareBsDates({year: 2076, month: 2, day: 1}, {year: 2076, month: 3, day: 1})
// Returns false
NepaliFunctions.CompareBsDates('2076-02-01', '2076-01-01')
// Returns true
NepaliFunctions.CompareBsDates('2076-02-01', '2076-03-01')
// Returns false

BetweenBsDates

This function returns if checkDate is between startDate and endDate

new BetweenBsDates(checkDate: object, startDate: object, endDate: object, dateFormat: string, inclusive: boolean): boolean
Parameters
checkDate (object) check date object or date string
startDate (object) start date object or date string
endDate (object) end date object or date string
dateFormat (string) any available date formats and required only if startDate or endDate is string
inclusive (boolean)
Returns
boolean: true if checkDate is between startDate and endDate
Example
NepaliFunctions.BetweenBsDates({year: 2076, month: 2, day: 5}, {year: 2076, month: 1, day: 1}, {year: 2076, month: 2, day: 10})
// Returns true
NepaliFunctions.BetweenBsDates({year: 2076, month: 1, day: 1}, {year: 2076, month: 1, day: 5}, {year: 2076, month: 2, day: 10})
// Returns false
NepaliFunctions.BetweenBsDates('2076-02-05', '2076-01-01', '2076-02-10')
// Returns true
NepaliFunctions.BetweenBsDates('2076-01-01', '2076-01-05', '2076-02-10')
// Returns false
NepaliFunctions.BetweenBsDates('2076/02/05', '2076/01/01', '2076/02/10', 'YYYY/MM/DD')
// Returns true
NepaliFunctions.BetweenBsDates('2076/01/01', '2076/01/05', '2076/02/10', 'YYYY/MM/DD')
// Returns false

ConvertToUnicode

This function converts number to unicode.

new ConvertToUnicode(number: number): string
Parameters
number (number) any number
Returns
string: that number converted to unicode string.
Example
NepaliFunctions.ConvertToUnicode(123456789)
// Returns १२३४५६७८९
NepaliFunctions.ConvertToUnicode(123.50)
// Returns १२३.५

ConvertToNumber

This function converts unicode to number.

new ConvertToNumber(unicode: string): number
Parameters
unicode (string) any unicode number
Returns
number: that number.
Example
NepaliFunctions.ConvertToNumber("१२३४५६७८९")
// Returns 123456789
NepaliFunctions.ConvertToNumber("१२३.५")
// Returns 123.5

NumberToWords

This function returns number to words in string.

new NumberToWords(number: number, isCurrency: boolean): string
Parameters
number (number) any number
isCurrency (boolean) true if you want to display currency
Returns
string: that number, converted to words.
Example
NepaliFunctions.NumberToWords(123456000.12, true)
// Returns Twelve Crore Thirty Four Lakh Fifty Six Thousand Rupees and Twelve Paisa
NepaliFunctions.NumberToWords(12, true)
NepaliFunctions.NumberToWords(123456000.12, false)
// Returns Twelve Crore Thirty Four Lakh Fifty Six Thousand
NepaliFunctions.NumberToWords(12, false)
// Returns Twelve

NumberToWordsUnicode

This function returns number to words in unicode string.

new NumberToWordsUnicode(number: number, isCurrency: boolean): string
Parameters
number (number) any number
isCurrency (boolean) true if you want to display currency
Returns
string: that number, converted to words in unicode.
Example
NepaliFunctions.NumberToWordsUnicode(123456000.12, true)
// Returns बाह्र करोड चौतीस लाख छपन्न हजार रुपैंया, बाह्र पैसा
NepaliFunctions.NumberToWordsUnicode(12, true)
NepaliFunctions.NumberToWordsUnicode(123456000.12, false)
// Returns बाह्र करोड चौतीस लाख छपन्न हजार
NepaliFunctions.NumberToWordsUnicode(12, false)
// Returns बाह्र