Skip to content

Commit e94ea17

Browse files
authored
Merge pull request #18 from dwyl/select
Select function
2 parents 5802af5 + c82b3d5 commit e94ea17

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

elm-package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.1.0",
2+
"version": "2.2.0",
33
"summary": "A customisable date picker written in Elm",
44
"repository": "https://github.com/dwyl/elm-datepicker.git",
55
"license": "BSD3",

src/DatePicker.elm

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ module DatePicker
2020
, previousMonth
2121
, nextMonth
2222
, receiveDate
23+
, setDate
2324
)
2425

2526
{-| A customisable DatePicker that easily allows you to select a range of dates
2627
27-
@docs DatePicker, Msg, Config, defaultConfig, initCalendar, showCalendar, update, Selection
28+
@docs DatePicker, Msg, Config, defaultConfig, initCalendar, showCalendar, update, Selection, receiveDate
2829
2930
3031
# Getter Functions
@@ -36,9 +37,20 @@ These functions allow you to access data from the DatePicker model.
3637
3738
# API Functions
3839
39-
These functions allow us to perform updates to the datepicker model
40+
These functions allow us to perform updates to the datepicker model. Just pass the datepicker as the last argument.
41+
For example:
4042
41-
@docs clearDates, toggleCalendar, cancelDates, previousMonth, nextMonth, receiveDate
43+
```Elm
44+
newDatepicker = DatePicker.setDate date datepicker
45+
```
46+
47+
Or
48+
49+
```Elm
50+
newDatePicker = DatePicker.clearDates datepicker
51+
```
52+
53+
@docs clearDates, toggleCalendar, cancelDates, previousMonth, nextMonth, setDate
4254
4355
-}
4456

@@ -557,3 +569,10 @@ nextMonth =
557569
receiveDate : Cmd Msg
558570
receiveDate =
559571
Task.perform ReceiveDate Date.now
572+
573+
574+
{-| Manually set the selected date
575+
-}
576+
setDate : Date -> DatePicker -> DatePicker
577+
setDate date =
578+
update (SelectDate (Just date))

0 commit comments

Comments
 (0)