Represents a Bikram Sambat date. Provides various methods to manipulate and format Bikram Sambat dates.

Implements

Constructors

Properties

adDate: Date
bsDay: number

This field will be removed or made private in upcoming versions. Please use .get('date') instead.

bsMonth: number

This field will be removed or made private in upcoming versions. Please use .get('month') instead.

bsMonthName: string
bsYear: number

This field will be removed or made private in upcoming versions. Please use .get('year') instead.

weekDay:
    | 0
    | 1
    | 2
    | 3
    | 4
    | 5
    | 6

This field will be removed or made private in upcoming versions. Please use .get('day') instead.

Methods

  • Returns a cloned BikramSambat object with a specified amount of time added.

    Parameters

    • value: number

      The amount of the specified unit to add to the date.

    • Optionalunit: ManipulateType = 'day'

      The unit of time to add. Valid units include 'day', 'month', 'year'.

    Returns BikramSambat

    A new BikramSambat date with the specified amount of time added

  • Creates and returns a deep copy of the current BikramSambat instance.

    Returns BikramSambat

    A new instance of BikramSambat with the same date properties.

  • Get or set the Bikram Sambat date.

    Parameters

    • Optionalvalue: number

      The date to set. If not provided, returns the current date.

    Returns number | BikramSambat

    The current date if no value is provided, otherwise a new BikramSambat instance with the updated date.

    Throws an error if the value is not a number.

  • Get or set the Bikram Sambat day of the week.

    Parameters

    • Optionalvalue: number

      The day of the week to set. If not provided, returns the current day of the week.

    Returns number | BikramSambat

    The current day of the week if no value is provided, otherwise a new BikramSambat instance with the updated day of the week.

    Throws an error if the value is not a number.

  • Returns a cloned BikramSambat object set to the end of the specified unit.

    Parameters

    • unit: StarOfEndOfType

      The unit to set to the end. Valid units include 'day', 'month', 'year'.

    Returns BikramSambat

    A new BikramSambat date set to the end of the specified unit

  • Formats the BikramSambat date according to the specified format string. Supported tokens:

    • YYYY: Full year
    • MM: Month number (zero-padded)
    • M: Month number
    • MMMM: Full month name
    • DD: Date (zero-padded)
    • D: Date
    • dddd: Full weekday name
    • ddd: Abbreviated weekday name
    • dd: Minimized weekday name
    • d: Day of the week

    Parameters

    • formatString: string

      The format string to use for formatting the date.

    Returns string

    The formatted date string.

  • Get the value of a specific unit (day, month, year, date).

    Parameters

    • unit:
          | "day"
          | "month"
          | "year"
          | "date"

      The unit type to get the value of ('day', 'month', 'year', 'date').

    Returns number

    The value of the specified unit.

    Throws an error if an invalid unit is provided.

  • Checks if the current BikramSambat date is after the given date.

    Parameters

    • date: BikramSambat | Date

      The date to compare with.

    • Optionalunit: UnitType = 'day'

      The unit of time to compare. Defaults to 'day'.

    Returns boolean

    True if the current date is after the given date, false otherwise.

    Throws an error if the value is not a instance of BikramSambat or Date.

  • Checks if the current BikramSambat date is before the given date.

    Parameters

    • date: BikramSambat | Date

      The date to compare with.

    • Optionalunit: UnitType = 'day'

      The unit of time to compare. Defaults to 'day'.

    Returns boolean

    True if the current date is before the given date, false otherwise.

    Throws an error if the value is not a instance of BikramSambat or Date.

  • Determines if a given BikramSambat or Date object falls between two specified dates, considering boundary inclusion.

    Supported boundaryInclusion values:

    • '()': Exclude both startDate and endDate
    • '[]': Include both startDate and endDate
    • '(]': Exclude startDate, include endDate
    • '[)': Include startDate, exclude endDate

    Parameters

    • startDate: BikramSambat | Date

      The start date to compare against.

    • endDate: BikramSambat | Date

      The end date to compare against.

    • Optionalunit: ManipulateType = 'day'

      The unit of time for comparison. Defaults to 'day'.

    • OptionalboundaryInclusion:
          | "()"
          | "(]"
          | "[)"
          | "[]" = '()'

      The boundary inclusion type for comparison. Defaults to '()'.

    Returns boolean

    True if the date is between startDate and endDate according to the specified boundaryInclusion, false otherwise.

  • Checks if the current BikramSambat date is the same as the given date.

    Parameters

    • date: BikramSambat | Date

      The date to compare with.

    • Optionalunit: UnitType = 'day'

      The unit of time to compare. Defaults to 'day'.

    Returns boolean

    True if the dates are the same, false otherwise.

    Throws an error if the value is not a instance of BikramSambat or Date.

  • Get or set the Bikram Sambat month.

    If setting the month, it adjusts the date to ensure it is valid within the new month.

    Parameters

    • Optionalvalue: number

      The month to set. If not provided, returns the current month.

    Returns number | BikramSambat

    • The current month if no value is provided, otherwise a new BikramSambat instance with the updated month.
    • Throws an error if the value is not a number.
  • Set the value of a specific unit (day, month, year, date).

    Parameters

    • unit:
          | "day"
          | "month"
          | "year"
          | "date"

      The unit type to set the value of ('day', 'month', 'year', 'date').

    • value: number

      The value to set for the specified unit.

    Returns BikramSambat

    A new BikramSambat instance with the updated unit value.

    Throws an error if the value is not a number.

  • Returns a cloned BikramSambat object set to the start of the specified unit.

    Parameters

    • unit: StarOfEndOfType

      The unit to set to the start. Valid units include 'day', 'month', 'year'.

    Returns BikramSambat

    A new BikramSambat date set to the start of the specified unit

  • Returns a cloned BikramSambat object with a specified amount of time subtracted.

    Parameters

    • value: number

      The amount of the specified unit to subtract from the date.

    • Optionalunit: ManipulateType = 'day'

      The unit of time to subtract. Valid units include 'day', 'month', 'year'.

    Returns BikramSambat

    A new BikramSambat date with the specified amount of time subtracted

  • Returns the BikramSambat object as a string.

    Returns string

    Formatted BikramSambat date as a formatted string MMMM D YYYY.

  • Get or set the Bikram Sambat year.

    If setting the year, it adjusts the date to ensure it is valid within the new year.

    Parameters

    • Optionalvalue: number

      The year to set. If not provided, returns the current year.

    Returns number | BikramSambat

    The current year if no value is provided, otherwise a new BikramSambat instance with the updated year.

    Throws an error if the value is not a number or is out of range (1970 - 2111).

  • Parses and validates the given AD date and returns an instance of BikramSambat for that date.

    Parameters

    • date: string | Date

      AD Date object or string to be parsed. Valid pattern for string: YYYY-MM-DD

    Returns BikramSambat

    An instance of BikramSambat

  • Returns a list of months and their total number of days of the year.

    Parameters

    • year: number

      Year to get the total number of days for each month.

    Returns {
        monthName: string;
        monthNumber: number;
        numberOfDays: number;
    }[]

    Array of months and their total number of days.

    Throws an error if the year is out of range (1970 - 2111) or invalid.

  • Parses and validates the given BS date and returns an instance of BikramSambat for that date.

    • BS Year must be between 1970 and 2111
    • BS Month must be between 1 and 12

    Parameters

    • date: string

      BS Date string to be parsed. Valid pattern: YYYY-MM-DD

    Returns BikramSambat

    An instance of BikramSambat