[INTL] Implement DateTime Format Functions
https://bugs.webkit.org/show_bug.cgi?id=147606
Patch by Andy VanWagoner <andy@instructure.com> on 2015-12-23
Reviewed by Benjamin Poulain.
Source/JavaScriptCore:
Initialize a UDateFormat from the generated pattern. Use udat_format()
to format the value. Make sure that the UDateFormat is cleaned up when
the DateTimeFormat is deconstructed.
* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::~IntlDateTimeFormat):
(JSC::IntlDateTimeFormat::initializeDateTimeFormat):
(JSC::IntlDateTimeFormat::format):
* runtime/IntlDateTimeFormat.h:
LayoutTests:
* js/intl-datetimeformat-expected.txt: Added format tests.
* js/intl-datetimeformat.html: Used utf-8.
* js/script-tests/intl-datetimeformat.js: Added format tests.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@194395 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h b/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h
index f0198ef..7dc57d0 100644
--- a/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h
+++ b/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h
@@ -29,6 +29,7 @@
#if ENABLE(INTL)
#include "JSDestructibleObject.h"
+#include <unicode/udat.h>
namespace JSC {
@@ -53,6 +54,7 @@
protected:
IntlDateTimeFormat(VM&, Structure*);
+ ~IntlDateTimeFormat();
void finishCreation(VM&);
static void destroy(JSCell*);
static void visitChildren(JSCell*, SlotVisitor&);
@@ -81,6 +83,7 @@
bool m_initializedDateTimeFormat { false };
void setFormatsFromPattern(const StringView&);
WriteBarrier<JSBoundFunction> m_boundFormat;
+ UDateFormat* m_dateFormat { nullptr };
String m_locale { ASCIILiteral("en") };
String m_calendar { ASCIILiteral("gregorian") };