23 using namespace utils;
30 std::size_t year_start = date.find_first_not_of(
' ');
31 if(year_start == std::string::npos) {
37 std::size_t year_end = date.find_first_of(
' ', year_start);
38 if(year_end == std::string::npos) {
39 year_end = date.size();
42 date_result.
year = std::stoi(date.substr(year_start, year_end - year_start));
44 std::size_t epoch_start = date.find_first_not_of(
' ', year_end);
45 if(epoch_start == std::string::npos) {
46 date_result.
epoch = wesnoth_epoch::type::wesnoth;
48 std::size_t epoch_end = date.find_first_of(
' ', epoch_start);
60 case wesnoth_epoch::type::before_wesnoth:
63 case wesnoth_epoch::type::wesnoth:
66 case wesnoth_epoch::type::before_fall:
69 case wesnoth_epoch::type::after_fall:
87 if(
a.get_epoch() <
b.get_epoch()) {
91 if(
a.get_epoch() >
b.get_epoch()) {
96 if(
a.get_epoch() == wesnoth_epoch::type::before_wesnoth ||
a.get_epoch() == wesnoth_epoch::type::before_fall) {
97 return (
a.get_year() >
b.get_year());
99 return (
a.get_year() <
b.get_year());
120 return a.get_year() ==
b.get_year() &&
a.get_epoch() ==
b.get_epoch();
Calendar for handling and comparing dates using the common epoches of the storyline.
static irdya_date read_date(const std::string &date)
wesnoth_epoch::type epoch
std::string to_string() const
bool operator!=(const irdya_date &a, const irdya_date &b)
bool operator<=(const irdya_date &a, const irdya_date &b)
bool operator>(const irdya_date &a, const irdya_date &b)
bool operator==(const irdya_date &a, const irdya_date &b)
std::map< std::string, t_string > string_map
bool operator>=(const irdya_date &a, const irdya_date &b)
std::ostream & operator<<(std::ostream &s, const irdya_date &d)
bool operator<(const irdya_date &a, const irdya_date &b)
static constexpr std::optional< enum_type > get_enum(const std::string_view value)
Converts a string into its enum equivalent.
static map_location::DIRECTION s