souporserious / calendar-fns

Small utility functions for building calendars in JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

đź—“ calendar-fns

Small utility functions for building calendars in JavaScript.

Exported Functions

getMonthWeekDays

import React from 'react'
import getMonthWeekDays from 'calendar-utils/getMonthWeekDays'

function CalendarWeekDays() {
  const weekdays = getMonthWeekDays()
  return (
    <tr>
      {weekdays.map(weekday => (
        <th>{weekday}</th>
      ))}
    </tr>
  )
}

getMonthWeeks

import React from 'react'
import getMonthWeeks from 'calendar-utils/getMonthWeeks'

function CalendarWeeks() {
  const weeks = getMonthWeeks()
  return weeks.map(week => (
    <tr>
      {week.map(day => (
        <td>{day})</td>
      ))}
    </tr>
  ))
}

getYears

import React from 'react'
import getYears from 'calendar-utils/getYears'

function YearPicker({ onYearClick }) {
  const years = getYears()
  return years.map(year => (
    <button onClick={() => onYearClick(year)}>{year}</button>
  ))
}

Exported Constants

TODAY

YEARS_PER_PAGE

DAYS_IN_WEEK

DAYS_IN_SIX_WEEKS

MONTHS

WEEKDAYS

About

Small utility functions for building calendars in JavaScript.

License:MIT License


Languages

Language:TypeScript 94.8%Language:JavaScript 5.2%