MCPcopy Index your code
hub / github.com/feiyu563/PrometheusAlert / diff

Function diff

static/plugins/chart.js/Chart.bundle.js:17973–18005  ·  view source on GitHub ↗
(input, units, asFloat)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

cloneWithOffsetFunction · 0.85
normalizeUnitsFunction · 0.85
monthDiffFunction · 0.85
absFloorFunction · 0.85

Tested by

no test coverage detected