#include "TimeInfoPkg.h"
#include <time.h>
#include <string>

TimeInfoPkg::TimeInfoPkg(int a, time_t time, bool ack) : TelepatiPkg(){
  type=TIMEINFO;
  aibo=a;
  needAck=ack;
  clockTime=time;
}

TimeInfoPkg::TimeInfoPkg(byte* ptr) : TelepatiPkg(ptr){
  memcpy(&clockTime, (ptr+STD_HEADER_SIZE), sizeof(time_t));
}


TimeInfoPkg::~TimeInfoPkg(){
}

TelepatiPkg* TimeInfoPkg::clone(){
  TimeInfoPkg* clone=new TimeInfoPkg(aibo, clockTime, needAck);
  clone->serialNum=serialNum;
  return clone;
}



byte* TimeInfoPkg::getMsg(){
  delete [] message;
  message=createStdHeader(sizeof(time_t));
  memcpy((message+STD_HEADER_SIZE), &clockTime, sizeof(time_t));  
  return message;
}
