#include "stdafx.h" #include std::string rDefaultDateTimeFormat = "%c"; rTimeSpan::rTimeSpan() { handle = static_cast(new wxTimeSpan()); } rTimeSpan::~rTimeSpan() { delete static_cast(handle); } rTimeSpan::rTimeSpan(const rTimeSpan& other) { handle = static_cast(new wxTimeSpan(*static_cast(other.handle))); } rTimeSpan::rTimeSpan(int a, int b , int c, int d) { handle = static_cast(new wxTimeSpan(a,b,c,d)); } rDateSpan::rDateSpan() { handle = static_cast(new wxDateSpan()); } rDateSpan::~rDateSpan() { delete static_cast(handle); } rDateSpan::rDateSpan(const rDateSpan& other) { handle = static_cast(new wxDateSpan(*static_cast(other.handle))); } rDateSpan::rDateSpan(int a, int b, int c, int d) { handle = static_cast(new wxDateSpan(a,b,c,d)); } rDateTime::rDateTime() { handle = static_cast(new wxDateTime()); } rDateTime::~rDateTime() { delete static_cast(handle); } rDateTime::rDateTime(const rDateTime& other) { handle = static_cast(new wxDateTime(*static_cast(other.handle))); } rDateTime::rDateTime(const time_t& time) { handle = static_cast(new wxDateTime(time)); } rDateTime::rDateTime(u16 day, rDateTime::Month month, u16 year, u16 hour, u16 minute, u16 second, u32 millisecond) { handle = static_cast(new wxDateTime(day,(wxDateTime::Month)month,year,hour,minute,second,millisecond)); } rDateTime rDateTime::UNow() { rDateTime time; delete static_cast(time.handle); time.handle = static_cast(new wxDateTime(wxDateTime::UNow())); return time; } rDateTime rDateTime::FromUTC(bool val) { rDateTime time(*this); void *temp = time.handle; time.handle = static_cast(new wxDateTime(static_cast(temp)->FromTimezone(wxDateTime::GMT0, val))); delete static_cast(temp); return time; } rDateTime rDateTime::ToUTC(bool val) { rDateTime time(*this); void *temp = time.handle; time.handle = static_cast(new wxDateTime(static_cast(temp)->ToTimezone(wxDateTime::GMT0, val))); delete static_cast(temp); return time; } time_t rDateTime::GetTicks() { return static_cast(handle)->GetTicks(); } void rDateTime::Add(const rTimeSpan& span) { static_cast(handle)->Add(*static_cast(span.handle)); } void rDateTime::Add(const rDateSpan& span) { static_cast(handle)->Add(*static_cast(span.handle)); } wxDateTime::TimeZone convertTZ(rDateTime::rTimeZone tz) { switch (tz) { case rDateTime::Local: return wxDateTime::Local; case rDateTime::GMT0: return wxDateTime::GMT0; case rDateTime::UTC: return wxDateTime::UTC; default: throw std::string("WRONG DATETIME"); } } std::string rDateTime::Format(const std::string &format, const rTimeZone &tz) const { return fmt::ToUTF8(static_cast(handle)->Format(fmt::FromUTF8(format),convertTZ(tz))); } void rDateTime::ParseDateTime(const std::string & format) { static_cast(handle)->ParseDateTime(fmt::FromUTF8(format)); } u32 rDateTime::GetAsDOS() { return static_cast(handle)->GetAsDOS(); } rDateTime &rDateTime::SetFromDOS(u32 fromdos) { static_cast(handle)->SetFromDOS(fromdos); return *this; } bool rDateTime::IsLeapYear(int year, rDateTime::Calender cal) { if (cal == Gregorian) { return wxDateTime::IsLeapYear(year, wxDateTime::Gregorian); } else { return wxDateTime::IsLeapYear(year, wxDateTime::Julian); } } int rDateTime::GetNumberOfDays(rDateTime::Month month, int year, rDateTime::Calender cal) { if (cal == Gregorian) { return wxDateTime::GetNumberOfDays(static_cast(month), year, wxDateTime::Gregorian); } else { return wxDateTime::GetNumberOfDays(static_cast(month), year, wxDateTime::Julian); } } void rDateTime::SetToWeekDay(rDateTime::WeekDay day, int n, rDateTime::Month month, int year) { static_cast(handle)->SetToWeekDay( static_cast(day) , n , static_cast(month) , year ); } int rDateTime::GetWeekDay() { return static_cast(handle)->GetWeekDay(); } u16 rDateTime::GetYear(rDateTime::TZ timezone) { return static_cast(handle)->GetYear(convertTZ(timezone)); } u16 rDateTime::GetMonth(rDateTime::TZ timezone) { return static_cast(handle)->GetMonth(convertTZ(timezone)); } u16 rDateTime::GetDay(rDateTime::TZ timezone) { return static_cast(handle)->GetDay(convertTZ(timezone)); } u16 rDateTime::GetHour(rDateTime::TZ timezone) { return static_cast(handle)->GetHour(convertTZ(timezone)); } u16 rDateTime::GetMinute(rDateTime::TZ timezone) { return static_cast(handle)->GetMinute(convertTZ(timezone)); } u16 rDateTime::GetSecond(rDateTime::TZ timezone) { return static_cast(handle)->GetSecond(convertTZ(timezone)); } u32 rDateTime::GetMillisecond(rDateTime::TZ timezone) { return static_cast(handle)->GetMillisecond(convertTZ(timezone)); }