@@ -27,19 +27,12 @@ namespace {
2727class_instance<C$DateTimeImmutable> clone_immutable (const class_instance<C$DateTimeImmutable>& origin) noexcept {
2828 class_instance<C$DateTimeImmutable> clone;
2929 clone.alloc ();
30- clone->time = kphp::timelib::clone (origin->time );
30+ clone->time = kphp::timelib::clone (* origin->time );
3131 return clone;
3232}
3333
3434} // namespace
3535
36- C$DateTimeImmutable::~C$DateTimeImmutable() {
37- if (time != nullptr ) {
38- kphp::timelib::destruct (time);
39- time = nullptr ;
40- }
41- }
42-
4336class_instance<C$DateTimeImmutable> f$DateTimeImmutable$$__construct(const class_instance<C$DateTimeImmutable>& self, const string& datetime,
4437 const class_instance<C$DateTimeZone>& timezone) noexcept {
4538 const auto & str_to_parse{datetime.empty () ? StringLibConstants::get ().NOW_STR : datetime};
@@ -50,7 +43,7 @@ class_instance<C$DateTimeImmutable> f$DateTimeImmutable$$__construct(const class
5043 THROW_EXCEPTION (kphp::exception::make_throwable<C$Exception>(err_msg));
5144 }
5245
53- timelib_time* time{*expected_time};
46+ kphp::timelib:: time_t time{std::move ( *expected_time) };
5447 timelib_tzinfo* tzi{!timezone.is_null () ? timezone->tzi : nullptr };
5548 if (tzi == nullptr ) {
5649 if (time->tz_info != nullptr ) {
@@ -60,16 +53,16 @@ class_instance<C$DateTimeImmutable> f$DateTimeImmutable$$__construct(const class
6053 }
6154 }
6255
63- kphp::timelib::fill_holes ( time, tzi);
56+ kphp::timelib::fill_holes_with_now (* time, tzi);
6457
65- self->time = time;
58+ self->time = std::move ( time) ;
6659 return self;
6760}
6861
6962class_instance<C$DateTimeImmutable> f$DateTimeImmutable$$add(const class_instance<C$DateTimeImmutable>& self,
7063 const class_instance<C$DateInterval>& interval) noexcept {
71- auto new_date = clone_immutable (self);
72- new_date->time = kphp::timelib::add (new_date->time , interval->rel_time );
64+ auto new_date{ clone_immutable (self)} ;
65+ new_date->time = kphp::timelib::add (* new_date->time , * interval->rel_time );
7366 return new_date;
7467}
7568
@@ -82,31 +75,31 @@ class_instance<C$DateTimeImmutable> f$DateTimeImmutable$$createFromFormat(const
8275 auto time{std::move (*expected_time)};
8376 timelib_tzinfo* tzi{!timezone.is_null () ? timezone->tzi : nullptr };
8477 if (tzi == nullptr ) {
85- if (time. tz_info != nullptr ) {
86- tzi = time. tz_info ;
78+ if (time-> tz_info != nullptr ) {
79+ tzi = time-> tz_info ;
8780 } else if (auto * default_tzi{kphp::timelib::get_timezone_info (TimeInstanceState::get ().default_timezone .c_str ())}; default_tzi != nullptr ) {
8881 tzi = default_tzi;
8982 }
9083 }
9184
92- kphp::timelib::fill_holes <true >(time, tzi);
85+ kphp::timelib::fill_holes_with_now <true >(* time, tzi);
9386
9487 class_instance<C$DateTimeImmutable> date_time;
9588 date_time.alloc ();
96- date_time->time = time;
89+ date_time->time = std::move ( time) ;
9790 return date_time;
9891}
9992
10093class_instance<C$DateTimeImmutable> f$DateTimeImmutable$$createFromMutable(const class_instance<C$DateTime>& object) noexcept {
10194 class_instance<C$DateTimeImmutable> clone;
10295 clone.alloc ();
103- clone->time = kphp::timelib::clone (object->time );
96+ clone->time = kphp::timelib::clone (* object->time );
10497 return clone;
10598}
10699
107100class_instance<C$DateTimeImmutable> f$DateTimeImmutable$$modify(const class_instance<C$DateTimeImmutable>& self, const string& modifier) noexcept {
108- auto new_date = clone_immutable (self);
109- auto expected_success = kphp::timelib::modify (new_date->time , {modifier.c_str (), modifier.size ()});
101+ auto new_date{ clone_immutable (self)} ;
102+ auto expected_success{ kphp::timelib::modify (* new_date->time , {modifier.c_str (), modifier.size ()})} ;
110103 if (!expected_success.has_value ()) [[unlikely]] {
111104 kphp::log::warning (" DateTimeImmutable::modify(): failed to parse modifier ({}): {}" , modifier.c_str (), expected_success.error ());
112105 return {};
@@ -115,22 +108,22 @@ class_instance<C$DateTimeImmutable> f$DateTimeImmutable$$modify(const class_inst
115108}
116109
117110class_instance<C$DateTimeImmutable> f$DateTimeImmutable$$setTimestamp(const class_instance<C$DateTimeImmutable>& self, int64_t timestamp) noexcept {
118- auto new_date = clone_immutable (self);
119- kphp::timelib::date_timestamp_set (new_date->time , timestamp);
111+ auto new_date{ clone_immutable (self)} ;
112+ kphp::timelib::date_timestamp_set (* new_date->time , timestamp);
120113 return new_date;
121114}
122115
123116class_instance<C$DateInterval> f$DateTimeImmutable$$diff(const class_instance<C$DateTimeImmutable>& self,
124117 const class_instance<C$DateTimeInterface>& target_object, bool absolute) noexcept {
125118 class_instance<C$DateInterval> interval;
126119 interval.alloc ();
127- interval->rel_time = kphp::timelib::date_diff (self->time , target_object.get ()->time , absolute);
120+ interval->rel_time = kphp::timelib::date_diff (* self->time , * target_object.get ()->time , absolute);
128121 return interval;
129122}
130123
131124string f$DateTimeImmutable$$format(const class_instance<C$DateTimeImmutable>& self, const string& format) noexcept {
132125 string str;
133- kphp::timelib::date_format_to_localtime (std::back_inserter (str), {format.c_str (), format.size ()}, self->time );
126+ kphp::timelib::date_format_to_localtime (std::back_inserter (str), {format.c_str (), format.size ()}, * self->time );
134127 return str;
135128}
136129
0 commit comments