mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 19:29:16 +00:00
LibSQL: Add a helper to convert a SQL::Value to a UnixDateTime
Support for constructing a Value from a UnixDateTime was added in commit
effcd080ca.
That constructor just stores the value as the number of milliseconds
since epoch. There's no way for outside users to know this, so this adds
a helper to retrieve the value as a UnixDateTime and let SQL::Value be
the source of truth for how the value is encoded/decoded.
This commit is contained in:
committed by
Andreas Kling
parent
1205d39fc3
commit
cd0e07f6a4
@@ -277,6 +277,15 @@ Optional<bool> Value::to_bool() const
|
||||
});
|
||||
}
|
||||
|
||||
Optional<UnixDateTime> Value::to_unix_date_time() const
|
||||
{
|
||||
auto time = to_int<i64>();
|
||||
if (!time.has_value())
|
||||
return {};
|
||||
|
||||
return UnixDateTime::from_milliseconds_since_epoch(*time);
|
||||
}
|
||||
|
||||
Optional<Vector<Value>> Value::to_vector() const
|
||||
{
|
||||
if (is_null() || (type() != SQLType::Tuple))
|
||||
|
||||
Reference in New Issue
Block a user