#include "timestamp.hpp" #include #include #include namespace MWWorld { TimeStamp::TimeStamp (float hour, int day) : mHour (hour), mDay (day) { if (hour<0 || hour>=24 || day<0) throw std::runtime_error ("invalid time stamp"); } float TimeStamp::getHour() const { return mHour; } int TimeStamp::getDay() const { return mDay; } TimeStamp& TimeStamp::operator+= (double hours) { if (hours<0) throw std::runtime_error ("can't move time stamp backwards in time"); hours += mHour; mHour = static_cast (std::fmod (hours, 24)); mDay += static_cast(hours / 24); return *this; } bool operator== (const TimeStamp& left, const TimeStamp& right) { return left.getHour()==right.getHour() && left.getDay()==right.getDay(); } bool operator!= (const TimeStamp& left, const TimeStamp& right) { return !(left==right); } bool operator< (const TimeStamp& left, const TimeStamp& right) { if (left.getDay()right.getDay()) return false; return left.getHour() (const TimeStamp& left, const TimeStamp& right) { return !(left<=right); } bool operator>= (const TimeStamp& left, const TimeStamp& right) { return !(left