@@ -63,53 +63,60 @@ capabilities::Inlineable<xsd_date>::cpp_type capabilities::Inlineable<xsd_date>:
63
63
return capabilities::Inlineable<xsd_date>::cpp_type{YearMonthDay::time_point<int64_t >{YearMonthDay::time_point<int64_t >::duration{i}}, std::nullopt };
64
64
}
65
65
66
- rdf4cpp::TimePoint date_to_tp (YearMonthDay const &d) noexcept {
67
- return rdf4cpp::util::construct_timepoint (d, rdf4cpp::util::time_point_replacement_time_of_day);
66
+ inline capabilities::Promotable<xsd_date>::promoted_cpp_type< 0 > date_to_tp (capabilities::Default<xsd_date>::cpp_type const &d) noexcept {
67
+ return std::make_pair ( rdf4cpp::util::construct_timepoint (d. first , rdf4cpp::util::time_point_replacement_time_of_day), d. second );
68
68
}
69
69
70
70
template <>
71
71
template <>
72
- capabilities::Promotable<xsd_date>::promoted_cpp_type<0 > capabilities::Promotable<xsd_date>::promote<0 >(cpp_type const &value) noexcept {
73
- return std::make_pair (date_to_tp (value.first ), value.second );
72
+ nonstd::expected<capabilities::Promotable<xsd_date>::promoted_cpp_type<0 >, DynamicError>
73
+ capabilities::Promotable<xsd_date>::promote<0 >(cpp_type const &value) noexcept {
74
+ return date_to_tp (value);
74
75
}
75
76
76
77
template <>
77
78
template <>
78
- nonstd::expected<capabilities::Promotable<xsd_date>::cpp_type, DynamicError> capabilities::Promotable<xsd_date>::demote<0 >(promoted_cpp_type<0 > const &value) noexcept {
79
+ nonstd::expected<capabilities::Promotable<xsd_date>::cpp_type, DynamicError>
80
+ capabilities::Promotable<xsd_date>::demote<0 >(promoted_cpp_type<0 > const &value) noexcept {
79
81
return std::make_pair (YearMonthDay{std::chrono::floor<std::chrono::days>(value.first )}, value.second );
80
82
}
81
83
82
84
template <>
83
85
std::partial_ordering capabilities::Comparable<xsd_date>::compare(cpp_type const &lhs, cpp_type const &rhs) noexcept {
84
- return rdf4cpp::datatypes::registry::util::compare_time_points (date_to_tp (lhs. first ), lhs. second , date_to_tp (rhs. first ), rhs. second );
86
+ return rdf4cpp::datatypes::registry::util::compare_time_points (date_to_tp (lhs), date_to_tp (rhs) );
85
87
}
86
88
87
89
template <>
88
90
nonstd::expected<capabilities::Timepoint<xsd_date>::timepoint_sub_result_cpp_type, DynamicError>
89
91
capabilities::Timepoint<xsd_date>::timepoint_sub(cpp_type const &lhs, cpp_type const &rhs) noexcept {
90
- auto const super_lhs = Promotable<xsd_date>::promote (lhs);
91
- auto const super_rhs = Promotable<xsd_date>::promote (rhs);
92
- return util::timepoint_sub (super_lhs, super_rhs);
92
+ auto const lhs_tp = date_to_tp (lhs);
93
+ auto const rhs_tp = date_to_tp (rhs);
94
+
95
+ return util::timepoint_sub (lhs_tp, rhs_tp);
93
96
}
94
97
95
98
template <>
96
99
nonstd::expected<capabilities::Timepoint<xsd_date>::cpp_type, DynamicError>
97
100
capabilities::Timepoint<xsd_date>::timepoint_duration_add(cpp_type const &tp, timepoint_duration_operand_cpp_type const &dur) noexcept {
98
101
auto const super_tp = Promotable<xsd_date>::promote (tp);
99
- auto res_tp = util::add_duration_to_date_time (super_tp.first , dur);
102
+ assert (super_tp.has_value ());
103
+
104
+ auto res_tp = util::add_duration_to_date_time (super_tp->first , dur);
100
105
101
106
auto [date, _] = rdf4cpp::util::deconstruct_timepoint (res_tp);
102
- return std::make_pair (date, super_tp. second );
107
+ return std::make_pair (date, super_tp-> second );
103
108
}
104
109
105
110
template <>
106
111
nonstd::expected<capabilities::Timepoint<xsd_date>::cpp_type, DynamicError>
107
112
capabilities::Timepoint<xsd_date>::timepoint_duration_sub(cpp_type const &tp, timepoint_duration_operand_cpp_type const &dur) noexcept {
108
113
auto const super_tp = Promotable<xsd_date>::promote (tp);
109
- auto res_tp = util::add_duration_to_date_time (super_tp.first , std::make_pair (-dur.first , -dur.second ));
114
+ assert (super_tp.has_value ());
115
+
116
+ auto res_tp = util::add_duration_to_date_time (super_tp->first , std::make_pair (-dur.first , -dur.second ));
110
117
111
118
auto [date, _] = rdf4cpp::util::deconstruct_timepoint (res_tp);
112
- return std::make_pair (date, super_tp. second );
119
+ return std::make_pair (date, super_tp-> second );
113
120
}
114
121
115
122
#endif
0 commit comments