(input, units, asFloat)
| 17971 | } |
| 17972 | |
| 17973 | function diff (input, units, asFloat) { |
| 17974 | var that, |
| 17975 | zoneDelta, |
| 17976 | output; |
| 17977 | |
| 17978 | if (!this.isValid()) { |
| 17979 | return NaN; |
| 17980 | } |
| 17981 | |
| 17982 | that = cloneWithOffset(input, this); |
| 17983 | |
| 17984 | if (!that.isValid()) { |
| 17985 | return NaN; |
| 17986 | } |
| 17987 | |
| 17988 | zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4; |
| 17989 | |
| 17990 | units = normalizeUnits(units); |
| 17991 | |
| 17992 | switch (units) { |
| 17993 | case 'year': output = monthDiff(this, that) / 12; break; |
| 17994 | case 'month': output = monthDiff(this, that); break; |
| 17995 | case 'quarter': output = monthDiff(this, that) / 3; break; |
| 17996 | case 'second': output = (this - that) / 1e3; break; // 1000 |
| 17997 | case 'minute': output = (this - that) / 6e4; break; // 1000 * 60 |
| 17998 | case 'hour': output = (this - that) / 36e5; break; // 1000 * 60 * 60 |
| 17999 | case 'day': output = (this - that - zoneDelta) / 864e5; break; // 1000 * 60 * 60 * 24, negate dst |
| 18000 | case 'week': output = (this - that - zoneDelta) / 6048e5; break; // 1000 * 60 * 60 * 24 * 7, negate dst |
| 18001 | default: output = this - that; |
| 18002 | } |
| 18003 | |
| 18004 | return asFloat ? output : absFloor(output); |
| 18005 | } |
| 18006 | |
| 18007 | function monthDiff (a, b) { |
| 18008 | // difference in months |
nothing calls this directly
no test coverage detected