# DateParams
A simple Elixir library that use the [Calendar][calendar] library to convert values of a map into Elixir 1.3's native date types. This is especially useful when used as a plug to deal with user-inputted dates.
### Example
```elixir
map = %{"date" => "2015-03-12"}
DateParams.to_structs(map, [["date"]])
#=> %{"date" => ~D[2015-03-12]}
```
### Using it as a plug
```elixir
defmodule Project.PageController do
use Project.Web, :controller
plug DateParams.Plug, [["vacation"], ["starts_at"], ["vacation"] ["ends_at"]]
end
```
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed as:
1. Add `date_params` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:date_params, "~> 0.1.0"}]
end
```
2. Ensure `date_params` is started before your application:
```elixir
def application do
[applications: [:date_params]]
end
```
# TODO
- [ ] Add `Time` support
- [ ] Add timezone support
- [ ] Look into supporting other datetime formats (HTTP and various RFC formats)
- [ ] Look into supporting natural language dates (like [Chronic][chronic])
[calendar]: https://hexdocs.pm/calendar/api-reference.html
[chronic]: https://github.com/radar/chronic