sutoiku / formula.js

JavaScript implementation of most Microsoft Excel formula functions
Other
2.14k stars 293 forks source link

Handle DATE() parameters the same as excel does. #52

Open stevebroshar opened 8 years ago

stevebroshar commented 8 years ago

I'm interested in using formula.js, and it's important the functions act like excel does. This PR modifies DATE() to handle the parameters like excel does. It adds 1900 to year it it's 0..1899, errors if year is >9999, and allows negative month and day values -- which js handles correctly by selecting a date at a negative month/day offset.

I guess one might argue that adding 1900 to a year like 1899 (to get 3799!) is of questionable value, but it is what excel does.

I also added test cases. And I added more structure to the tests -- closer to the ideal of one assert per test.

This will probably be the first PR from me. I will submit more if this one seems good and when I find issues with other functions.

stevebroshar commented 8 years ago

Since I didn't hear back on this change for a while, I forked the davidpolberger branch and implemented my changes on that code line. So, there's not much value in only merging in this one little change.

I am concerned that development of the project has become fractured into many different branches. But, I don't know how to improve that situation.