Skip to content

Commit eb0dc06

Browse files
committed
fixes
1 parent 8bad775 commit eb0dc06

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

runtime-light/stdlib/time/datetime.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class_instance<C$DateTime> f$DateTime$$__construct(const class_instance<C$DateTi
1818
auto expected{kphp::timelib::parse_time(std::string_view{str_to_parse.c_str(), str_to_parse.size()})};
1919
if (!expected.has_value()) [[unlikely]] {
2020
string err_msg;
21-
std::format_to(kphp::string_back_insert_iterator{.ref = err_msg}, "DateTime::__construct(): Failed to parse time string ({}) {}", datetime.c_str(), expected.error());
21+
std::format_to(kphp::string_back_insert_iterator{.ref = err_msg}, "DateTime::__construct(): Failed to parse time string ({}) {}", datetime.c_str(),
22+
expected.error());
2223
TimeInstanceState::get().update_last_errors(std::move(expected.error()));
2324
THROW_EXCEPTION(kphp::exception::make_throwable<C$Exception>(err_msg));
2425
return {};

runtime-light/stdlib/time/timelib-functions.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ std::expected<rel_time, error_container> parse_interval(std::string_view interva
8080
int r{}; // it's intentionally declared as 'int' since timelib_strtointerval accepts 'int'
8181
timelib_error_container* errors{nullptr};
8282

83-
kphp::memory::libc_alloc_guard{},
84-
timelib_strtointerval(interval_sv.data(), interval_sv.size(), std::addressof(b), std::addressof(e), std::addressof(p), std::addressof(r), std::addressof(errors));
83+
kphp::memory::libc_alloc_guard{}, timelib_strtointerval(interval_sv.data(), interval_sv.size(), std::addressof(b), std::addressof(e), std::addressof(p),
84+
std::addressof(r), std::addressof(errors));
8585

8686
if (errors->error_count > 0) {
8787
kphp::timelib::details::rel_time_destructor{}(p);
@@ -101,8 +101,8 @@ std::expected<rel_time, error_container> parse_interval(std::string_view interva
101101
return std::unexpected{error_container{errors}};
102102
}
103103

104-
time add(const kphp::timelib::time& t, timelib_rel_time& interval) noexcept {
105-
time new_time{(kphp::memory::libc_alloc_guard{}, timelib_add(t.get(), std::addressof(interval)))};
104+
time add_time_interval(const kphp::timelib::time& t, const kphp::timelib::rel_time& interval) noexcept {
105+
time new_time{(kphp::memory::libc_alloc_guard{}, timelib_add(t.get(), interval.get()))};
106106
return new_time;
107107
}
108108

@@ -372,12 +372,12 @@ void set_time(const kphp::timelib::time& t, int64_t h, int64_t i, int64_t s, int
372372
kphp::memory::libc_alloc_guard{}, timelib_update_ts(t.get(), nullptr);
373373
}
374374

375-
std::expected<time, std::string_view> sub(const kphp::timelib::time& t, timelib_rel_time& interval) noexcept {
376-
if (interval.have_special_relative) {
375+
std::expected<time, std::string_view> sub_time_interval(const kphp::timelib::time& t, const kphp::timelib::rel_time& interval) noexcept {
376+
if (interval->have_special_relative) {
377377
return std::unexpected{"Only non-special relative time specifications are supported for subtraction"};
378378
}
379379

380-
time new_time{(kphp::memory::libc_alloc_guard{}, timelib_sub(t.get(), std::addressof(interval)))};
380+
time new_time{(kphp::memory::libc_alloc_guard{}, timelib_sub(t.get(), interval.get()))};
381381
return new_time;
382382
}
383383

0 commit comments

Comments
 (0)