mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibCore: Add DateTime::from_timestamp(time_t)
This commit is contained in:
@@ -32,7 +32,11 @@ namespace Core {
|
||||
|
||||
DateTime DateTime::now()
|
||||
{
|
||||
auto timestamp = time(nullptr);
|
||||
return from_timestamp(time(nullptr));
|
||||
}
|
||||
|
||||
DateTime DateTime::from_timestamp(time_t timestamp)
|
||||
{
|
||||
struct tm tm;
|
||||
localtime_r(×tamp, &tm);
|
||||
DateTime dt;
|
||||
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
String to_string() const;
|
||||
|
||||
static DateTime now();
|
||||
static DateTime from_timestamp(time_t);
|
||||
|
||||
private:
|
||||
time_t m_timestamp { 0 };
|
||||
|
||||
Reference in New Issue
Block a user