#include "mytime.h"
#include<iomanip>
#include<iostream>
#include<cmath>
using namespace std;
MyTime::MyTime()
{
this->hour=0;
this->minue=0;
}
MyTime::MyTime(int h,int m){
this->hour=h;
this->minue=m;
MyTime::normalizeTime();
}
MyTime::MyTime(int minutes)
{
hour=minutes/60;
minue=minutes%60;
}
void MyTime::setTime(int h,int m){
hour=h;
minue=m;
MyTime::normalizeTime();
}
void MyTime::output()const
{
cout<<setfill('0')<<setw(2)<<hour<<":"<<setfill('0')<<setw(2)<<minue<<endl;
}
int MyTime::getHour() const
{
return hour;
}
int MyTime::getMinue() const
{
return minue;
}
int MyTime::getTotalMinutes() const
{
return 60*hour+minue;
}
void MyTime::normalizeTime()
{
if(this->hour>23)
this->hour=this->hour%24;
if(this->minue>59)
this->hour+=this->minue/60;
this->minue=this->minue%60;
}
MyTime MyTime::getTimeSpan(const MyTime &t)const
{
int sum1=hour*60+minue;
int sum2=t.hour*60+t.minue;
int sum=abs(sum1-sum2);
int h=sum/60;
int m=sum%60;
MyTime p(h,m);
return p;
}