mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-29 11:00:29 +00:00
LibWeb: Add CSS::Time::to_milliseconds()
This commit is contained in:
parent
b7e3a68bfc
commit
f07c4ffbc8
Notes:
sideshowbarker
2024-07-16 23:52:10 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/f07c4ffbc8 Pull-request: https://github.com/SerenityOS/serenity/pull/19050 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/Lubrsi
2 changed files with 12 additions and 0 deletions
|
@ -47,6 +47,17 @@ float Time::to_seconds() const
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
double Time::to_milliseconds() const
|
||||
{
|
||||
switch (m_type) {
|
||||
case Type::S:
|
||||
return static_cast<double>(m_value) * 1000.0;
|
||||
case Type::Ms:
|
||||
return static_cast<double>(m_value);
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
StringView Time::unit_name() const
|
||||
{
|
||||
switch (m_type) {
|
||||
|
|
|
@ -27,6 +27,7 @@ public:
|
|||
|
||||
ErrorOr<String> to_string() const;
|
||||
float to_seconds() const;
|
||||
double to_milliseconds() const;
|
||||
|
||||
Type type() const { return m_type; }
|
||||
float raw_value() const { return m_value; }
|
||||
|
|
Loading…
Reference in a new issue