1.0.16 • Published 1 year ago

calendar-creator v1.0.16

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

npm.io npm

useCalendar

(useCalendar name was taken 😢 so it goes under calendar-creator)

Minimal hook for generating logic for calendars

Example use

  • Initializing calendar
import { useCalendar } from 'calendar-creator'

const { interval, monthInText } = useCalendar({ inputDate: new Date() })
  • Using with Locale and custom dateFormat
/* Locales are imported seperately from date-fns
   and not included in package */

import fr from 'date-fns/locale/fr'

const {decrement, increment, interval, monthInText } = useCalendar({
    inputDate: new Date(),
    dateFormat: 'dd/MM/yyyy',
    locale: fr
})

Using calendardata

  • Map over interval
  • Use provided formatterfunc to apply default or provided format
const App = () => {
	const { interval, formatter } = useCalendar({ inputDate: new Date(), dateFormat: 'dd/MM/yyyy' })

	return (
		<div>
			{interval.map((date) => (
                {/* Date will be formatted to dd/MM/yyyy */}
				<div key={date.getTime()}>{formatter(date)}</div>
			))}
		</div>
	)
}
1.0.16

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago