/*
 * Copyright (c) 2006 AWS Convergence Technologies, Inc. 
 * All rights reserved.
 * Visit http://www.aws.com
 *
 * WBTime.js
 *
 * This scripts contains the WBTime resuable class. A WBTime object takes care
 * of dealing with system time and checking for refresh rates.
 */

// Object Definition
function WBTime()
{
	this.timeObject = new Date(); // local JS date object
}

WBTime.prototype.currentTime = function ()
{
	// To get the current time, delete the time object and initialize a new one.
	// Then return the current time from the new object
	delete this.timeObject;
	this.timeObject = new Date();
	return this.timeObject.getTime();
}

WBTime.prototype.checkForUpdate = function (timeIn,rate)
{
	// If timeIn exists, and the difference between the times is greater than the update time
	// then reload. Otherwise, don't reload.

	if(timeIn)
	{
		var difference = this.currentTime() - timeIn;
		if(difference > rate){ return true; }
	}
	else { return true; }
	return false;
}

WBTime.prototype.currentDay = function ()
{
	// Return the current day for today
	delete this.timeObject;
	this.timeObject = new Date();
	return this.timeObject.getDay();
}