////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DateTime Object
function spdt(year, month, day, hour, min, second, offset) {
  // Second Calc	
  this._minute = 60;
	this._hour   = 3600;
	this._day    = 86400;
	this._week   = 604800;

  // Store parameters
  this.year = year;
  this.month = month;
  this.day = day;
  this.hour = hour;
  this.min = min;
  this.second = second;
  this.offset = offset;
  
  this.time = util_convert_string_to_int(timedate_create_time_str(this.year, this.month, this.day, this.hour, this.min, this.second));
  
  this.epoch = Date.UTC(this.year, this.month - 1, this.day, this.hour, this.min, this.second, 0) / 1000;
  this.epoch -= this.offset * this._hour;
  
  if(timedate_is_dst(this.time)) {
    this.epoch += this._hour * -1;
  }
}

spdt.prototype.get_timestr = function() {
  return this.time;
}

spdt.prototype.get_offset = function() {
  return this.offset;
}

spdt.prototype.get_epoch = function() {
  return this.epoch;
}

//////////////////////////////////////////////////////////////////////////////

function timedate_create_time_str(year, month, day, hour, minute, second) {
  var str = "";
  str += year*1;
  if(month < 10) str += "0";
  str += month*1;
  if(day < 10) str += "0";
  str += day*1;
  if(hour < 10) str += "0";
  str += hour*1;
  if(minute < 10) str += "0";
  str += minute*1;
  if(second < 10) str += "0";
  str += second*1;
  return str;
}

function timedate_is_dst(timestr) {
      
  // 20080309 - 20081102
  if(timestr >= 20080309020000 && timestr < 20081102020000)
    return true;
    
  // 20090308 - 20091101
  if(timestr >= 20090308020000 && timestr < 20091101020000)
    return true;
    
  // 20100314 - 20101107
  if(timestr >= 20100314020000 && timestr < 20101107020000)
    return true;
    
  // 20110313 - 20111106
  if(timestr >= 20110313020000 && timestr < 20111106020000)
    return true;
   
  return false;
}
