21 using namespace utils;
28 std::size_t year_start = date.find_first_not_of(
' ');
29 if(year_start == std::string::npos) {
35 std::size_t year_end = date.find_first_of(
' ', year_start);
36 if(year_end == std::string::npos) {
37 year_end = date.size();
40 date_result.
year =
std::stoi(date.substr(year_start, year_end - year_start));
42 std::size_t epoch_start = date.find_first_not_of(
' ', year_end);
43 if(epoch_start == std::string::npos) {
44 date_result.
epoch = wesnoth_epoch::type::wesnoth;
46 std::size_t epoch_end = date.find_first_of(
' ', epoch_start);
58 case wesnoth_epoch::type::before_wesnoth:
61 case wesnoth_epoch::type::wesnoth:
64 case wesnoth_epoch::type::before_fall:
67 case wesnoth_epoch::type::after_fall:
94 if(a.
get_epoch() == wesnoth_epoch::type::before_wesnoth || a.
get_epoch() == wesnoth_epoch::type::before_fall) {
Calendar for handling and comparing dates using the common epoches of the storyline.
unsigned int get_year() const
static irdya_date read_date(const std::string &date)
wesnoth_epoch::type epoch
std::string to_string() const
wesnoth_epoch::type get_epoch() 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)
int stoi(std::string_view str)
Same interface as std::stoi and meant as a drop in replacement, except:
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 utils::optional< enum_type > get_enum(const std::string_view value)
Converts a string into its enum equivalent.
static map_location::direction s