toddler.date
calendar-month
(calendar-month value)
For given value of timestamp function will return days for month in form that at 6 weeks are included. First week will hold first day of month, than 4 weeks of that month and following weeks from next month.
Maximal possible weeks is 6 for this logic
reducer
multimethod
Reducer used to work with calendar. You can exend current functionalities by implementing defmethod for topic of :type
By default following is implemented:
- :clear
- :next-month
- :prev-month
- :next-year
- :prev-year
- :change-year
- :change-month
- :focus-value
- :focus-date
use-calendar-days
(use-calendar-days value days)
Hook that is usefull when working with date selection. For given value and sequence of days it will return input days extended with keys:
- :picked - true if value is in this day
- :today - true if value is today
use-calendar-month
(use-calendar-month {:keys [date value]})
Hook that will return state of calendar month and dispatch function. Based on either value or date it will create react state with toddler.date/reducer.
use-calendar-months
(use-calendar-months)
Hook will return map with numeric months bound to month names. Month names will depend on app/locale context value.
use-period-callback
(use-period-callback [start end :as period])
This hook will return fn that accepts day-time-context and computes next [start end]
period value based on picked day-time-context value. If date is higher than end return value will be expanded end period.
Same goes if input day-time-context is lower than start period.
If day-time-context is inbetween it will narrow closer limit. Either start or end
Start and End values should be js/Date
use-period-days
(use-period-days [start end] days)
Hook will process input days by comparing if each of input days is in [start end]
period.
Result will extended days with following keys:
- :today - boolean
- :selected - true if in period
- :period-start - true if day is same as start value day
- :period-end - true if day is same as end value day
use-week-days
(use-week-days)
Hook will return week days in short (three letter) format for current app/locale context value