rtfeldman / elm-iso8601-date-strings

Convert between ISO-8601 date strings and Time.Posix
https://package.elm-lang.org/packages/rtfeldman/elm-iso8601-date-strings/latest
BSD 3-Clause "New" or "Revised" License
34 stars 21 forks source link

Expose or extract yearMonthDay logic? #22

Closed ianmackenzie closed 3 years ago

ianmackenzie commented 5 years ago

I'm trying to parse dates/times from the Last-Modified header of an HTTP response. It's easy enough to write a parser to extract the year, month, day, hour, minute and second (certainly helps that the time is guaranteed to always be in GMT/UTC). However, if I want to convert that to a Time.Posix value, the options currently all seem a bit messy:

Would it make sense to take the core logic of dealing with month lengths, leap years etc. and either expose it from this package or (perhaps better) publish it as a separate package that elm-iso8601-data-strings could then depend on?

justinmimbs commented 5 years ago

Hi Ian,

I noticed that dmy/elm-imf-date-time was recently published, which parses such formats. Perhaps that may help.

Justin

ianmackenzie commented 5 years ago

Thanks Justin, very timely! Anything by @dmy is definitely worth checking out =)

Perhaps more relevantly to this specific issue, though, I see that elm-imf-date-time uses Time.Extra.partsToPosix from your own time-extra package - that's exactly the functionality I was looking for, and somehow I missed it when I was looking at different date/time packages.

So I think this issue can probably be closed since the functionality I was describing is in fact available in the time-extra package (thanks!), and now that elm-imf-date-time is published for my particular use case I can just switch to that myself and get rid of my parsing code as well.

jamesrweb commented 3 years ago

@rtfeldman can you close this issue when you have time since it seems to be resolved now? 😄