Options
All
  • Public
  • Public/Protected
  • All
Menu

calendar-fp

Index

Functions

Const arrayToMatrix

  • arrayToMatrix(array: readonly Date[], columns: number): any
  • Parameters

    • array: readonly Date[]
    • columns: number

    Returns any

getAllDates

  • getAllDates(currentMonth: Date): readonly Date[]
  • Get all dates from a month and some previous and next month dates for covering start and end of the week

    Example

    import { getAllDates } from '@calendar-fp/calendar-fp'
    console.log(getAllDates(new Date(2021, 0, 1)))
    // => [new Date(2020, 11, 27),
    //  new Date(2020, 11, 28),
    //  new Date(2020, 11, 29), ...]
    

    Parameters

    • currentMonth: Date

    Returns readonly Date[]

    string[] | Date[]

getAllDatesMatrix

  • getAllDatesMatrix(currentMonth: Date): any
  • Get all dates from a month and some previous and next month dates for covering start and end of the week, grouped by week

    Example

    import { getAllDatesMatrix } from '@calendar-fp/calendar-fp'
    console.log(getAllDatesMatrix(new Date(2021, 0, 1)))
    [
      [
        new Date(2020, 11, 27),
        new Date(2020, 11, 28),
        new Date(2020, 11, 29),
        ...
      ],
      [
        ...
      ]
      ...
    ]
    

    Parameters

    • currentMonth: Date

    Returns any

    Date[]

getDays

  • getDays(dayFormat?: string): readonly string[]
  • Get days of the week

    Example

    import { getDays } from '@calendar-fp/calendar-fp'
    console.log(getDays())
    // => ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
    

    Parameters

    • Default value dayFormat: string = "EEE"

      Optional day formatting

    Returns readonly string[]

    string[]

getMonthAndYear

  • getMonthAndYear(currentDate: Date, dateFormat?: string): string
  • Get month and year name for calendar navigation

    Example

    import { getMonthAndYear } from '@calendar-fp/calendar-fp'
    console.log(getMonthAndYear(new Date(2021, 2, 1)))
    // => March, 2021
    

    Parameters

    • currentDate: Date

      Current month as a Date object.

    • Default value dateFormat: string = "MMMM yyyy"

      Optional date format

    Returns string

    string

getNextMonth

  • getNextMonth(currentMonth: Date): Date
  • Get next month from a date

    Example

    import { getNextMonth } from '@calendar-fp/calendar-fp'
    console.log(getNextMonth(new Date(2021, 2, 1)))
    // => new Date(2021, 3, 1)
    

    Parameters

    • currentMonth: Date

      Current month as a Date object.

    Returns Date

    Date

getPrevMonth

  • getPrevMonth(currentMonth: Date): Date
  • Get previous month from a date

    Example

    import { getPrevMonth } from '@calendar-fp/calendar-fp'
    console.log(getPrevMonth(new Date(2021, 2, 1)))
    // => new Date(2021, 1, 1)
    

    Parameters

    • currentMonth: Date

      Current month as a Date object.

    Returns Date

    Date

Generated using TypeDoc