-
Notifications
You must be signed in to change notification settings - Fork 110
[k2] add Date/Time classes to light runtime #1481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
d1df9ec to
244c045
Compare
| class string { | ||
| public: | ||
| using size_type = string_size_type; | ||
| using value_type = char; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added to be able to use std::back_inserter
49fc0f4 to
a96050c
Compare
apolyakov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reviewed and noted some comments. Please, take into account that these comments should be applied to whole PR, not only the places where I left those comments
| inline constexpr std::string_view BACKSLASH_ = "\\"; | ||
| inline constexpr std::string_view QUOTE_ = "\""; | ||
| inline constexpr std::string_view NEWLINE_ = "\n"; | ||
| inline constexpr std::string_view NOW_ = "now"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the context for strings part of standard library. Let's move this to one specific for time functions
|
|
||
| #include "kphp/timelib/timelib.h" | ||
|
|
||
| #include "common/containers/final_action.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, remove all the unused includes
|
|
||
| using error_container_t = std::unique_ptr<timelib_error_container, destructor>; | ||
| using rel_time_t = std::unique_ptr<timelib_rel_time, destructor>; | ||
| using time_t = std::unique_ptr<timelib_time, destructor>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we have a mix of raw timelib types and our own wrappers in the API. It doesn't look like a good solution.
Also, please refactor exisiting code that uses raw types in case you add wrappers. Mixing types is always bad
|
|
||
| time_offset_t construct_time_offset(timelib_time& t) noexcept; | ||
|
|
||
| std::pair<time_t, error_container_t> parse_time(std::string_view time_sv) noexcept; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for us to have both valid time_t and error_container_t?
|
|
||
| std::pair<time_t, error_container_t> parse_time(std::string_view time_sv) noexcept; | ||
| std::pair<time_t, error_container_t> parse_time(std::string_view time_sv, const char* format) noexcept; | ||
| std::expected<rel_time_t, std::format_string<const char*>> parse_interval(std::string_view format) noexcept; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think it's not the best idea to return error format string instead of an error itself
|
|
||
| time_t add(timelib_time& t, timelib_rel_time& interval) noexcept; | ||
|
|
||
| rel_time_t clone(timelib_rel_time& rt) noexcept; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better to just create a wrapper class? As far as I see, it might be worth it since you already have clone and destruct
|
|
||
| void set_timestamp(timelib_time& t, int64_t timestamp) noexcept; | ||
|
|
||
| std::string_view english_suffix(timelib_sll number) noexcept; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it really be a part of public kphp::timelib API?
This first part of implementing Date/Time classes. Here implemented: