cullophid / date-fp

Functional programming date manipulation library
121 stars 17 forks source link

Set function always returns 'Invalid date' for 'days', 'months' and 'years' #46

Closed S-unya closed 8 years ago

S-unya commented 8 years ago

Dear Mr robot, Firstly, thanks for taking the time to write this lib, it is a good idea and has a nice, clean interface.

I hope that this testing is useful to you - I realise that it a little sparse but the following is what I consistently get with different dates. I believe it is because the string names expected in the setters here are date, month and year rather than the days, months and years suggested in the docs below.

I have tested this using the example code in the Docs here: https://evilcorp.limited/date-fp/docs/functions/set.html

These are my results: ` var date = new Date('2001-01-01 01:01:01.0'); // Mon Jan 01 2001 01:01:01 GMT+0000 (GMT)

var y = D.set('milliseconds', 123, date); // Mon Jan 01 2001 01:01:01 GMT+0000 (GMT)

var y = D.set('minutes', 13, date); // Mon Jan 01 2001 01:13:01 GMT+0000 (GMT)

var y = D.set('seconds', 13, date); // Mon Jan 01 2001 01:01:13 GMT+0000 (GMT)

var y = D.set('hours', 13, date); // Mon Jan 01 2001 13:01:01 GMT+0000 (GMT)

var y = D.set('days', 13, date); // Invalid Date

var y = D.set('months', 1, date); // Invalid Date

var y = D.set('years', 2015, date); // Invalid Date

// === TEST THEORY === // var y = D.set('year', 2015, date); // Thu Jan 01 2015 01:01:01 GMT+0000 (GMT) ` Tested in Chrome Canary only.

S-unya commented 8 years ago

I'm happy to normalise those for you if it helps?

cullophid commented 8 years ago

Thank you very much, I have updated the docs to show the correct keywords :)

cullophid commented 8 years ago

thank you for your help, please let us know if you find anything else :)