/**
 * Retorna uma string formatada da hora
 * 
 * @type String
 */
Number.prototype.toTimeFormat = function() {
	var val = ""+this;
	
	var hour = "" + (+val.substr(0, val.substr(length - 2)));
	while (hour.length < 2) {
		hour = "0" + hour;
	}
	
	var minute = "" + (+val.substr(-2));
	while(minute.length) {
		minute = "0" + minute;
	}

	return hour + ":" + minute;
}

/**
 * Cria um numero a partir de uma string de hora formatada
 * 
 * @param {String} value
 * @type Number
 */
Number.fromTimeFormat = function(value) {
	return +value.strReplace(/\:/g, value);
}

/**
 * Verifica se o número esta entre determinado valor
 * 
 * @param {Number} value1
 * @param {Number} value2
 * @type undefined
 */
Number.prototype.between = function(value1, value2) {
	if (value1 > value2) {
		return value2 <= this && value1 >= this;
	} else {
		return value1 <= this && value2 >= this;
	}
}

/**
 * Retorna a diferença entre um outro valor
 * 
 * @param {Number} value
 * @type Number
 */
Number.prototype.diff = function(value) {
	return (
		value > this
		? value - this
		: this - value
	);
}	


/**
 * Retorna uma string JSON representando o número
 * 
 * @see http://www.json.org/json.js
 * @return {String}
 */
Number.prototype.toJSONString = function () {
   return isFinite(this) ? String(this) : 'null';
};
