| 1 | #include <time/seadDateSpan.h> |
| 2 | #include <time/seadDateUtil.h> |
| 3 | |
| 4 | namespace sead |
| 5 | { |
| 6 | DateSpan::DateSpan(s64 span) : mSpan(span) {} |
| 7 | |
| 8 | DateSpan::DateSpan(const CalendarSpan::Day& d, const CalendarSpan::Hour& h, |
| 9 | const CalendarSpan::Minute& m, const CalendarSpan::Second& s) |
| 10 | { |
| 11 | set(d, h, m, s); |
| 12 | } |
| 13 | |
| 14 | DateSpan::DateSpan(const CalendarSpan& span) |
| 15 | { |
| 16 | set(span); |
| 17 | } |
| 18 | |
| 19 | s64 DateSpan::set(const CalendarSpan& span) |
| 20 | { |
| 21 | return setTimeImpl_(d: span.getDays(), h: span.getHours(), m: span.getMinutes(), s: span.getSeconds()); |
| 22 | } |
| 23 | |
| 24 | s64 DateSpan::set(const CalendarSpan::Day& d, const CalendarSpan::Hour& h, |
| 25 | const CalendarSpan::Minute& m, const CalendarSpan::Second& s) |
| 26 | { |
| 27 | return setTimeImpl_(d: d.getValue(), h: h.getValue(), m: m.getValue(), s: s.getValue()); |
| 28 | } |
| 29 | |
| 30 | void DateSpan::getCalendarSpan(CalendarSpan* out_span) const |
| 31 | { |
| 32 | DateUtil::calcSecondToCalendarSpan(out_span, seconds: mSpan); |
| 33 | } |
| 34 | |
| 35 | s64 DateSpan::setTimeImpl_(s32 d, s32 h, s32 m, s32 s) |
| 36 | { |
| 37 | mSpan = 86400ll * d + 3600ll * h + 60ll * m + s; |
| 38 | return mSpan; |
| 39 | } |
| 40 | |
| 41 | } // namespace sead |
| 42 | |