mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
LibJS: Implement (most of) Intl.DateTimeFormat.prototype.format
There are a few FIXMEs that will need to be addressed, but this implements most of the prototype method. The FIXMEs are mostly related to range formatting, which has been entirely ignored so far. But other than that, the following will need to be addressed: * Determining flexible day periods must be made locale-aware. * DST will need to be determined and acted upon. * Time zones other than UTC and calendars other than Gregorian are ignored. * Some of our results differ from other engines as they have some format patterns we do not. For example, they seem to have a lonely {dayPeriod} pattern, whereas our closest pattern is "{hour} {dayPeriod}".
This commit is contained in:
parent
d010ba10c3
commit
adaf5985a4
9 changed files with 977 additions and 8 deletions
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Tim Flynn <trflynn89@pm.me>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/NativeFunction.h>
|
||||
|
||||
namespace JS::Intl {
|
||||
|
||||
class DateTimeFormatFunction final : public NativeFunction {
|
||||
JS_OBJECT(DateTimeFormatFunction, NativeFunction);
|
||||
|
||||
public:
|
||||
static DateTimeFormatFunction* create(GlobalObject&, DateTimeFormat&);
|
||||
|
||||
explicit DateTimeFormatFunction(DateTimeFormat&, Object& prototype);
|
||||
virtual ~DateTimeFormatFunction() override = default;
|
||||
virtual void initialize(GlobalObject&) override;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
||||
private:
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
DateTimeFormat& m_date_time_format; // [[DateTimeFormat]]
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue