Class BSLocalDate

Hierarchy

Constructors

  • Constructor, previously validated.

    Parameters

    • year: number

      the year to represent, from MIN_YEAR to MAX_YEAR

    • month: Month

      the month-of-year to represent, not null

    • dayOfMonth: number

      the day-of-month to represent, valid for year-month, from 1 to 31

    Returns BSLocalDate

Properties

REFERENCE_DATE: BSLocalDate = ...
yearMonthSpanLookupTable: number[][] = ...

Accessors

  • get day(): number
  • Returns number

  • get dayOfMonth(): number
  • Gets the day-of-month field.

    This method returns the primitive int value for the day-of-month.

    Returns

    the day-of-month, from 1 to 31

    Returns number

  • Returns the day of week, taking account of the weekOfMonth.

    This returns the day of week of current day. For example, a day placed in Sunday would return 0.

    Returns DayOfWeek

  • get dayOfYear(): number
  • Gets the day-of-year field.

    This method returns the primitive int value for the day-of-year.

    Returns

    the day-of-year, from 1 to 365, or 366 in a leap year

    Returns number

  • get daysSinceReferenceDate(): number
  • Returns number

  • get lengthOfMonth(): number
  • Returns the length of the month, taking account of the year.

    This returns the length of the month in days. For example, a date in January would return 31.

    Returns

    the length of the month in days, from 28 to 31

    Returns number

  • get lengthOfYear(): number
  • Returns the length of the year.

    This returns the length of the year in days, either 365 or 366.

    Returns

    366 if the year is leap, 365 otherwise

    Returns number

  • Returns Month

  • get monthName(): string
  • Gets the name of month-of-year.

    This method returns the month name as an String.

    Returns

    the name of month-of-year

    Returns string

  • get monthValue(): number
  • Gets the month-of-year field from 1 to 12.

    This method returns the month as an int from 1 to 12. Application code is frequently clearer if the enum [Month] is used by calling [.getMonth].

    Returns

    the month-of-year, from 1 to 12

    Returns number

  • The type of calendar.

    Returns LocalDateType

  • get year(): number
  • Returns number

Methods

  • Checks if this date is after the specified date.

    This checks to see if this date represents a point on the local time-line after the other date.

       const a = ILocalDate.ofBS(2077, 6, 20)
       const b = ILocalDate.ofBS(2077, 7, 1)
      a.after(b) == false
      a.after(a) == false
      b.after(a) == true
    

    Returns

    true if this date is after the specified date

    Parameters

    • other: ILocalDate

      the other date to compare to, not null

    Returns boolean

  • Checks if this date is before the specified date.

    This checks to see if this date represents a point on the local time-line before the other date.

       const a = ILocalDate.ofBS(2077, 6, 20)
       const b = ILocalDate.ofBS(2077, 7, 1)
      a.before(b) == true
      a.before(a) == false
      b.before(a) == false
    

    This method only considers the position of the two dates on the local time-line. It does not take into account the chronology, or calendar system. This is different from the comparison in [#compareTo(ChronoLocalDate)](../modules.html), but is the same approach as ChronoLocalDate#timeLineOrder().

    Returns

    true if this date is before the specified date

    Parameters

    • other: ILocalDate

      the other date to compare to, not null

    Returns boolean

  • Compares this date to another date.

    The comparison is primarily based on the date, from earliest to latest. It is "consistent with equals", as defined by Comparable.

    If all the dates being compared are instances of {@code ILocalDate}, then the comparison will be entirely based on the date.

    Returns

    the comparator value, negative if less, positive if greater

    Parameters

    • other: ILocalDate

      the other date to compare to, not null

    Returns number

  • daysSum(month: Month): number
  • Parameters

    Returns number

  • equals(other?: object): boolean
  • Checks if this date is equal to another date.

    Compares this {@code ILocalDate} with another ensuring that the date is the same.

    Only objects of type {@code ILocalDate} are compared, other types return false.

    Returns

    true if this is equal to the other date

    Parameters

    • Optional other: object

      the object to check, null returns false

    Returns boolean

  • firstDayOfYear(): number
  • hashCode(): number
  • A hash code for this date.

    Returns

    a suitable hash code

    Returns number

  • maxYear(): number
  • minYear(): number
  • Returns a copy of this {@code ILocalDate} with the specified number of days subtracted.

    This method subtracts the specified amount from the days field decrementing the month and year fields as necessary to ensure the result remains valid. The result is only invalid if the maximum/minimum year is exceeded.

    For example, 2009-01-01 minus one day would result in 2008-12-31.

    This instance is immutable and unaffected by this method call.

    Returns

    a {@code ILocalDate} based on this date with the days subtracted

    Parameters

    • daysToSubtract: number

      the days to subtract, may be negative

    Returns ILocalDate

  • minusMonths(monthsToSubtract: number): ILocalDate
  • Returns a copy of this {@code ILocalDate} with the specified number of months subtracted.

    This method subtracts the specified amount from the months field in three steps:

    1. Subtract the input months from the month-of-year field
    2. Check if the resulting date would be invalid
    3. Adjust the day-of-month to the last valid day if necessary

    For example, 2007-03-31 minus one month would result in the invalid date 2007-02-31. Instead of returning an invalid result, the last valid day of the month, 2007-02-28, is selected instead.

    This instance is immutable and unaffected by this method call.

    Returns

    a {@code ILocalDate} based on this date with the months subtracted

    Parameters

    • monthsToSubtract: number

      the months to subtract, may be negative

    Returns ILocalDate

  • Returns a copy of this {@code ILocalDate} with the specified number of years subtracted.

    This method subtracts the specified amount from the years field in three steps:

    1. Subtract the input years from the year field
    2. Check if the resulting date would be invalid
    3. Adjust the day-of-month to the last valid day if necessary

    For example, 2008-02-29 (leap year) minus one year would result in the invalid date 2007-02-29 (standard year). Instead of returning an invalid result, the last valid day of the month, 2007-02-28, is selected instead.

    This instance is immutable and unaffected by this method call.

    Returns

    a {@code ILocalDate} based on this date with the years subtracted

    Parameters

    • yearsToSubtract: number

      the years to subtract, may be negative

    Returns ILocalDate

  • Returns a copy of this {@code ILocalDate} with the specified number of days added.

    This method adds the specified amount to the days field incrementing the month and year fields as necessary to ensure the result remains valid. The result is only invalid if the maximum/minimum year is exceeded.

    For example, 2008-12-31 plus one day would result in 2009-01-01.

    This instance is immutable and unaffected by this method call.

    Returns

    a {@code ILocalDate} based on this date with the days added

    Parameters

    • daysToAdd: number

      the days to add, may be negative

    Returns ILocalDate

  • Returns a copy of this {@code ILocalDate} with the specified number of months added.

    This method adds the specified amount to the months field in three steps:

    1. Add the input months to the month-of-year field
    2. Check if the resulting date would be invalid
    3. Adjust the day-of-month to the last valid day if necessary

    For example, 2007-03-31 plus one month would result in the invalid date 2007-04-31. Instead of returning an invalid result, the last valid day of the month, 2007-04-30, is selected instead.

    This instance is immutable and unaffected by this method call.

    Returns

    a {@code ILocalDate} based on this date with the months added

    Parameters

    • monthsToAdd: number

      the months to add, may be negative

    Returns ILocalDate

  • Returns a copy of this {@code ILocalDate} with the specified number of years added.

    This method adds the specified amount to the years field in three steps:

    1. Add the input years to the year field
    2. Check if the resulting date would be invalid
    3. Adjust the day-of-month to the last valid day if necessary

    For example, 2008-02-29 (leap year) plus one year would result in the invalid date 2009-02-29 (standard year). Instead of returning an invalid result, the last valid day of the month, 2009-02-28, is selected instead.

    This instance is immutable and unaffected by this method call.

    Returns

    a {@code ILocalDate} based on this date with the years added

    Parameters

    • yearsToAdd: number

      the years to add, may be negative

    Returns ILocalDate

  • Returns the start week of month, taking account of the weekOfMonth.

    This returns the start weekDay of current month. For example, a month started with Sunday would return 0.

    Returns

    the starting day of month

    Returns DayOfWeek

  • toString(): string
  • Outputs this date as a {@code String}, such as {@code 2007-12-03 (BS)}.

    The output will be in the ISO-8601 format {@code uuuu-MM-dd}.

    Returns

    a string representation of this date, not null

    Returns string

  • convertToBS(year: number, month: number, dayOfMonth: number): ILocalDate
  • monthDays(year: number): number[]
  • Parameters

    • year: number

    Returns number[]

  • Obtains an instance of {@code ILocalDate} from a year, month and day.

    This returns a {@code ILocalDate} with the specified year, month and day-of-month. The day must be valid for the year and month, otherwise an exception will be thrown.

    Returns

    the local date, not null

    Parameters

    • year: number

      the year to represent, from MIN_YEAR to MAX_YEAR

    • month: number = 1

      the month-of-year to represent, from 1 (January) to 12 (December)

    • dayOfMonth: number = 1

      the day-of-month to represent, from 1 to 31

    • type: LocalDateType = LocalDateType.BS

      the type of calendar to represent by AD or BS

    Returns ILocalDate

  • ofAD(year: number, month?: number, dayOfMonth?: number): ILocalDate
  • ofBS(year: number, month?: number, dayOfMonth?: number): ILocalDate
  • yearIndex(year: number): number
  • Parameters

    • year: number

    Returns number

Generated using TypeDoc