choptastic / qdate

Erlang date, time, and timezone management: formatting, conversion, and date arithmetic
http://sigma-star.com/blog/post/qdate
MIT License
247 stars 82 forks source link

add_months(-12) being executed on 2018-01-05 throws function_clause #35

Closed jairov4 closed 6 years ago

jairov4 commented 6 years ago

look the weird behavior:

3> qdate:add_months(-11).
1486320803
4> qdate:add_months(-14).
1478372009
5> qdate:add_months(-13).
1480964011
6> qdate:add_months(-12).
** exception error: no function clause matching calendar:last_day_of_the_month1(2016,13) (calendar.erl, line 244)
     in function  qdate:add_months/2 (/***/_build/default/lib/qdate/src/qdate.erl, line 625)
7> qdate:add_months(-11).
1486320816
8> qdate:add_months(-10).
1488740150
9> os:timestamp().
{1515,178569,325880}
choptastic commented 6 years ago

That certainly is odd behavior. If you're down with working on a patch for that, I'm happy to merge it. Otherwise, I can find some time to work on it myself.

You feeling down to get dirty with the code?

-Jesse

On Jan 5, 2018 12:58 PM, "jairov4" notifications@github.com wrote:

look the weird behavior:

3> qdate:add_months(-11). 1486320803 4> qdate:add_months(-14). 1478372009 5> qdate:add_months(-13). 1480964011 6> qdate:add_months(-12). ** exception error: no function clause matching calendar:last_day_of_the_month1(2016,13) (calendar.erl, line 244) in function qdate:add_months/2 (/***/_build/default/lib/qdate/src/qdate.erl, line 625) 7> qdate:add_months(-11). 1486320816 8> qdate:add_months(-10). 1488740150 9> os:timestamp(). {1515,178569,325880}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/choptastic/qdate/issues/35, or mute the thread https://github.com/notifications/unsubscribe-auth/AALYnNgMAYR-azDwe3f0QqXHfF8Uiualks5tHnDagaJpZM4RU0Qu .

choptastic commented 6 years ago

Nevermind, I found some time and almost have the fix done.

-Jesse

On Fri, Jan 5, 2018 at 1:28 PM, Jesse Gumm sigmastar@gmail.com wrote:

That certainly is odd behavior. If you're down with working on a patch for that, I'm happy to merge it. Otherwise, I can find some time to work on it myself.

You feeling down to get dirty with the code?

-Jesse

On Jan 5, 2018 12:58 PM, "jairov4" notifications@github.com wrote:

look the weird behavior:

3> qdate:add_months(-11). 1486320803 4> qdate:add_months(-14). 1478372009 5> qdate:add_months(-13). 1480964011 6> qdate:add_months(-12). ** exception error: no function clause matching calendar:last_day_of_the_month1(2016,13) (calendar.erl, line 244) in function qdate:add_months/2 (/***/_build/default/lib/qdate/src/qdate.erl, line 625) 7> qdate:add_months(-11). 1486320816 8> qdate:add_months(-10). 1488740150 9> os:timestamp(). {1515,178569,325880}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/choptastic/qdate/issues/35, or mute the thread https://github.com/notifications/unsubscribe-auth/AALYnNgMAYR-azDwe3f0QqXHfF8Uiualks5tHnDagaJpZM4RU0Qu .

-- Jesse Gumm Owner, Sigma Star Systems 414.940.4866 || sigma-star.com || @jessegumm