Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support decode datetime #180

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jeffhsta
Copy link

Linked to #174

To use the datetime decode feature is just need to request it in the options, like:

%{now: Time.utc_now()}
|> Poison.encode!()
|> Poison.decode!(format_datetime: :time)

# %{"now" => ~T[02:24:23.871934]}

%{now: Date.utc_today()}
|> Poison.encode!()
|> Poison.decode!(format_datetime: :date)

# %{"now" => ~D[2018-10-11]}

%{now: DateTime.utc_now()}
|> Poison.encode!()
|> Poison.decode!(format_datetime: :datetime)

# %{"now" => #DateTime<2018-10-11 02:25:05.251816Z>}

%{now: NaiveDateTime.utc_now()}
|> Poison.encode!()
|> Poison.decode!(format_datetime: :naive_datetime)

# %{"now" => ~N[2018-10-11 02:25:13.460277]}

@coveralls
Copy link

Pull Request Test Coverage Report for Build 245

  • 21 of 27 (77.78%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-1.03%) to 88.393%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/poison/parser.ex 21 27 77.78%
Totals Coverage Status
Change from base Build 236: -1.03%
Covered Lines: 198
Relevant Lines: 224

💛 - Coveralls

@devinus devinus force-pushed the master branch 22 times, most recently from 29a475d to e0a080a Compare July 23, 2021 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants