timrwood/moment — pull request #192 by hsablonniere (2012-03-03 14:01:03+00:00)
Title: Formatted diffs

Hi Tim,

We talked about formatted diffs in #143. My code is ready to be discussed and reviewed! I encountered some problems and I have questions here's some details...

* My function doesn't work if units aren't in decreasing order. Is it a problem? Should we throw an Error? I can work on a different implementation that can handle that case, but code will be bigger and maybe slower.
* I assume that DST is always 1 hour but it's not ALWAYS the case. What do you think we should do about that?
* The ```calendar``` function doesn't work anymore, but I'm not sure I'm responsible. ;-) You'll find details by running the tests. Please tell me if I've done something wrong.
* Some tests in diff weren't correct :

```
test.equal(moment([2010]).diff([2010, 0, 21], 'weeks'), -3, "week diff");
```
January 1st to January 21th => 20 days => not 3 weeks

```
test.equal(moment([2010]).diff([2011, 6], 'years', true), -1.5, "year diff, float");
```
In France, DST change accurs in March so this diff is not exactly 1.5 years. What do you think we should do about that?

There's problably adjusments to make the code better, prettier or faster, feel free to make any remarks I'll correct my PR...

Thanks again for this library and for letting me having huge headaches on this ;-)

Regards.