
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}".
33 lines
815 B
C++
33 lines
815 B
C++
/*
|
|
* 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]]
|
|
};
|
|
|
|
}
|