mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
LibCore/DateTime: Add helper for setting only the date from another date
This commit is contained in:
parent
251e5fb074
commit
985db495be
2 changed files with 6 additions and 0 deletions
|
@ -95,6 +95,11 @@ void DateTime::set_time_only(int hour, int minute, Optional<int> second)
|
||||||
set_time(year(), month(), day(), hour, minute, second.has_value() ? second.release_value() : this->second());
|
set_time(year(), month(), day(), hour, minute, second.has_value() ? second.release_value() : this->second());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DateTime::set_date(Core::DateTime const& other)
|
||||||
|
{
|
||||||
|
set_time(other.year(), other.month(), other.day(), hour(), minute(), second());
|
||||||
|
}
|
||||||
|
|
||||||
ErrorOr<String> DateTime::to_string(StringView format) const
|
ErrorOr<String> DateTime::to_string(StringView format) const
|
||||||
{
|
{
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
|
|
||||||
void set_time(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0);
|
void set_time(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0);
|
||||||
void set_time_only(int hour, int minute, Optional<int> second = {});
|
void set_time_only(int hour, int minute, Optional<int> second = {});
|
||||||
|
void set_date(Core::DateTime const& other);
|
||||||
ErrorOr<String> to_string(StringView format = "%Y-%m-%d %H:%M:%S"sv) const;
|
ErrorOr<String> to_string(StringView format = "%Y-%m-%d %H:%M:%S"sv) const;
|
||||||
ByteString to_byte_string(StringView format = "%Y-%m-%d %H:%M:%S"sv) const;
|
ByteString to_byte_string(StringView format = "%Y-%m-%d %H:%M:%S"sv) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue