1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:38:11 +00:00

LibCore: Add a primitive comparison function to DateTime

This should go away when we get the ability to parse strings to
DateTime's.
This commit is contained in:
AnotherTest 2020-05-07 09:11:07 +04:30 committed by Andreas Kling
parent 3df3ab4598
commit d051fffe25
2 changed files with 10 additions and 0 deletions

View file

@ -280,6 +280,12 @@ String DateTime::to_string(const String& format) const
return builder.build();
}
bool DateTime::is_before(const String& other) const
{
auto now_string = String::format("%04d%02d%02d%02d%02d%02dZ", year(), month(), weekday(), hour(), minute(), second());
return __builtin_strcasecmp(now_string.characters(), other.characters()) < 0;
}
const LogStream& operator<<(const LogStream& stream, const DateTime& value)
{
return stream << value.to_string();