date-frequency
Advanced tools
Comparing version 0.4.2 to 0.4.3
@@ -221,10 +221,23 @@ var util = require('./util'), | ||
Frequency.prototype.compare = function (frequency) { | ||
// warning: only compares those units that appear in both frequencies, with both the same scope! | ||
for (var i = 0;i < util.unit.order.length;i++) { | ||
var unit = util.unit.order[i]; | ||
if (this.rules[unit] && frequency.rules[unit] && this.rules[unit].scope === frequency.rules[unit].scope) { | ||
if (this.rules[unit].fix < frequency.rules[unit].fix) { | ||
return -1; | ||
} else if (this.rules[unit].fix > frequency.rules[unit].fix) { | ||
return 1; | ||
var unit = util.unit.order[i], | ||
rule1 = this.rules[unit], | ||
rule2 = frequency.rules[unit]; | ||
if (!rule1 && rule2) { | ||
return -1; | ||
} else if (rule1 && !rule2) { | ||
return 1; | ||
} else if (rule1 && rule2) { | ||
var scope = rule1.scope; | ||
if (scope === rule2.scope) { | ||
var value1 = this.getValue(unit, scope), | ||
value2 = frequency.getValue(unit, scope); | ||
if (value1 < value2) { | ||
return -1; | ||
} else if (value1 > value2) { | ||
return 1; | ||
} | ||
} | ||
@@ -231,0 +244,0 @@ } |
{ | ||
"name": "date-frequency", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "Temporal frequency library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
16550
436