rluiten / elm-date-extra

Elm Date Extra library add/subtract/diff/format etc dates
http://package.elm-lang.org/packages/rluiten/elm-date-extra/latest
BSD 3-Clause "New" or "Revised" License
75 stars 36 forks source link

Problem with dayList #28

Closed ksamborski closed 7 years ago

ksamborski commented 7 years ago

I have the following line of code: Debug.log "dayList" <| dayList (daysInMonth 2017 10) <| dateFromFields 2017 10 1 0 0 0 0

And when I open the browser I see this in console: dayList: [ <Sun Oct 01 2017 00:00:00 GMT+0200 (CEST)>,
<Mon Oct 02 2017 00:00:00 GMT+0200 (CEST)>,
<Tue Oct 03 2017 00:00:00 GMT+0200 (CEST)>,
<Wed Oct 04 2017 00:00:00 GMT+0200 (CEST)>,
<Thu Oct 05 2017 00:00:00 GMT+0200 (CEST)>,
<Fri Oct 06 2017 00:00:00 GMT+0200 (CEST)>,
<Sat Oct 07 2017 00:00:00 GMT+0200 (CEST)>,
<Sun Oct 08 2017 00:00:00 GMT+0200 (CEST)>,
<Mon Oct 09 2017 00:00:00 GMT+0200 (CEST)>,
<Tue Oct 10 2017 00:00:00 GMT+0200 (CEST)>,
<Wed Oct 11 2017 00:00:00 GMT+0200 (CEST)>,
<Thu Oct 12 2017 00:00:00 GMT+0200 (CEST)>,
<Fri Oct 13 2017 00:00:00 GMT+0200 (CEST)>,
<Sat Oct 14 2017 00:00:00 GMT+0200 (CEST)>,
<Sun Oct 15 2017 00:00:00 GMT+0200 (CEST)>,
<Mon Oct 16 2017 00:00:00 GMT+0200 (CEST)>,
<Tue Oct 17 2017 00:00:00 GMT+0200 (CEST)>,
<Wed Oct 18 2017 00:00:00 GMT+0200 (CEST)>,
<Thu Oct 19 2017 00:00:00 GMT+0200 (CEST)>,
<Fri Oct 20 2017 00:00:00 GMT+0200 (CEST)>,
<Sat Oct 21 2017 00:00:00 GMT+0200 (CEST)>,
<Sun Oct 22 2017 00:00:00 GMT+0200 (CEST)>,
<Mon Oct 23 2017 00:00:00 GMT+0200 (CEST)>,
<Tue Oct 24 2017 00:00:00 GMT+0200 (CEST)>,
<Wed Oct 25 2017 00:00:00 GMT+0200 (CEST)>,
<Thu Oct 26 2017 00:00:00 GMT+0200 (CEST)>,
<Fri Oct 27 2017 00:00:00 GMT+0200 (CEST)>,
<Sat Oct 28 2017 00:00:00 GMT+0200 (CEST)>,
<Sun Oct 29 2017 00:00:00 GMT+0200 (CEST)>,
<Sun Oct 29 2017 23:00:00 GMT+0100 (CET)>,
<Mon Oct 30 2017 23:00:00 GMT+0100 (CET)>]

Interesting lines are the two last ones. October 29 is mentioned twice. I think this is because of the time change in October. But I think this is a bug because the name of the function is "dayList" which clearly doesn't return what it says. I ended up using List.uniqueBy Date.day from list-extra package on the result.

rluiten commented 7 years ago

Another day light saving hiccup, thanks for the report. I hope to get to it soon, havn't had much time with Elm recently.

bjorse commented 7 years ago

I've discovered problems with October as well. When I call toFirstOfMonth for October, I actually get October the 2nd, not the 1st.

rluiten commented 7 years ago

I just started holidays and have been looking at issues that have been pending, sorry for the long delay. I have a fix for dayList done in code base.

Was taking a look at toFirstOfMonth problem but so far have not been able to reproduce it. Can you give me an exact date you give to toFirstofMonth that is failing.

Is it correct based on your previous example you on are in Central European Time and Central European Summer Time zone ?

rluiten commented 7 years ago

I believe I have an example of a problem not exactly yours but related I am sure.

toFirstOfMonth "2017-03-28" is "2017-03-01"

"2017-02-28T23:00:00.000"
╷
│ Expect.equal
╵
"2017-03-01T00:00:00.000"
rluiten commented 7 years ago

I have published a fix for a few issues in this thread along with some other issues in 8.5.0.

Thanks to your bug report @ksamborski Thanks to your additional input @bjorse which pointed out several related functions with problems with day light saving boundaries.

Please let me know if you have any further issues. Feel free to reopen this issue if you have further issues.

Thanks again.