/************************************
* Class Clock                       *
*                                   *
* Properties: day                   *
*               Input: -            *
*               Output: (Integer)   *
*             hours                 *
*               Input: -            *
*               Output: (Integer)   *
*             minutes               *
*               Input: -            *
*               Output: (Integer)   *
*             month                 *
*               Input: -            *
*               Output: (Integer)   *
*             seconds               *
*               Input: -            *
*               Output: (Integer)   *
*             year                  *
*               Input: -            *
*               Output: (Integer)   *
* Methods: set                      *
*            Input: (proc Function) *
*            Output: -              *
************************************/

function Clock()
{
  this.day = '';
  this.hours = '';
  this.minutes = '';
  this.month = '';
  this.seconds = '';
  this.year = '';

  function right(str)
  {
    return str.substring(str.length - 2);
  }

  this.set = function(proc)
  {
    var dateobj = new Date();
    var me = this;
    this.day = right('00' + dateobj.getDate());
    this.hours = right('00' + dateobj.getHours());
    this.minutes = right('00' + dateobj.getMinutes());
    this.month = right('00' + (dateobj.getMonth() + 1));
    this.seconds = right('00' + dateobj.getSeconds());
    this.year = dateobj.getFullYear();
    proc();
    window.setTimeout(function() { me.set(proc); }, 1000);
  };
}

