1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:17:35 +00:00

LibCore: Add a way to parse a DateTime from a string

DateTime can now be parsed from a string. Implements the same formatters
as strptime: https://linux.die.net/man/3/strptime (Well, some of them at
least).
This commit is contained in:
x-yl 2021-06-01 16:52:38 +04:00 committed by Ali Mohammad Pur
parent cbd7437d40
commit 904322e754
2 changed files with 282 additions and 0 deletions

View file

@ -35,6 +35,7 @@ public:
static DateTime create(unsigned year, unsigned month = 1, unsigned day = 0, unsigned hour = 0, unsigned minute = 0, unsigned second = 0);
static DateTime now();
static DateTime from_timestamp(time_t);
static Optional<DateTime> parse(const String& format, const String& string);
bool operator<(const DateTime& other) const { return m_timestamp < other.m_timestamp; }