14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_ci#ifndef ECMASCRIPT_BUILTINS_BUILTINS_DATE_H 174514f5e3Sopenharmony_ci#define ECMASCRIPT_BUILTINS_BUILTINS_DATE_H 184514f5e3Sopenharmony_ci 194514f5e3Sopenharmony_ci#include "ecmascript/base/builtins_base.h" 204514f5e3Sopenharmony_ci#include "ecmascript/js_date.h" 214514f5e3Sopenharmony_ci 224514f5e3Sopenharmony_ci// List of functions in Date, excluding the '@@' properties. 234514f5e3Sopenharmony_ci// V(name, func, length, stubIndex) 244514f5e3Sopenharmony_ci// where BuiltinsDate::func refers to the native implementation of Date[name]. 254514f5e3Sopenharmony_ci// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available. 264514f5e3Sopenharmony_ci#define BUILTIN_DATE_FUNCTIONS(V) \ 274514f5e3Sopenharmony_ci /* Date.now ( ) */ \ 284514f5e3Sopenharmony_ci V("now", Now, 0, DateNow) \ 294514f5e3Sopenharmony_ci /* Date.parse ( string ) */ \ 304514f5e3Sopenharmony_ci V("parse", Parse, 1, INVALID) \ 314514f5e3Sopenharmony_ci /* Date.UTC ( year [ , month [ , date [ , hours [ , minutes [ , seconds [ , ms ] ] ] ] ] ] ) */ \ 324514f5e3Sopenharmony_ci V("UTC", UTC, ::panda::ecmascript::builtins::BuiltinsDate::UTC_LENGTH, INVALID) 334514f5e3Sopenharmony_ci 344514f5e3Sopenharmony_ci// List of functions in Date.prototype, excluding the constructor and '@@' properties. 354514f5e3Sopenharmony_ci// V(name, func, length, stubIndex) 364514f5e3Sopenharmony_ci// where BuiltinsDate::func refers to the native implementation of Date.prototype[name]. 374514f5e3Sopenharmony_ci#define BUILTIN_DATE_PROTOTYPE_FUNCTIONS(V) \ 384514f5e3Sopenharmony_ci /* Date.prototype.getDate ( ) */ \ 394514f5e3Sopenharmony_ci V("getDate", GetDate, 0, INVALID) \ 404514f5e3Sopenharmony_ci /* Date.prototype.getDay ( ) */ \ 414514f5e3Sopenharmony_ci V("getDay", GetDay, 0, INVALID) \ 424514f5e3Sopenharmony_ci /* Date.prototype.getFullYear ( ) */ \ 434514f5e3Sopenharmony_ci V("getFullYear", GetFullYear, 0, INVALID) \ 444514f5e3Sopenharmony_ci /* Date.prototype.getHours ( ) */ \ 454514f5e3Sopenharmony_ci V("getHours", GetHours, 0, INVALID) \ 464514f5e3Sopenharmony_ci /* Date.prototype.getMilliseconds ( ) */ \ 474514f5e3Sopenharmony_ci V("getMilliseconds", GetMilliseconds, 0, INVALID) \ 484514f5e3Sopenharmony_ci /* Date.prototype.getMinutes ( ) */ \ 494514f5e3Sopenharmony_ci V("getMinutes", GetMinutes, 0, INVALID) \ 504514f5e3Sopenharmony_ci /* Date.prototype.getMonth ( ) */ \ 514514f5e3Sopenharmony_ci V("getMonth", GetMonth, 0, INVALID) \ 524514f5e3Sopenharmony_ci /* Date.prototype.getSeconds ( ) */ \ 534514f5e3Sopenharmony_ci V("getSeconds", GetSeconds, 0, INVALID) \ 544514f5e3Sopenharmony_ci /* Date.prototype.getTime ( ) */ \ 554514f5e3Sopenharmony_ci V("getTime", GetTime, 0, DateGetTime) \ 564514f5e3Sopenharmony_ci /* Date.prototype.getTimezoneOffset ( ) */ \ 574514f5e3Sopenharmony_ci V("getTimezoneOffset", GetTimezoneOffset, 0, INVALID) \ 584514f5e3Sopenharmony_ci /* Date.prototype.getUTCDate ( ) */ \ 594514f5e3Sopenharmony_ci V("getUTCDate", GetUTCDate, 0, INVALID) \ 604514f5e3Sopenharmony_ci /* Date.prototype.getUTCDay ( ) */ \ 614514f5e3Sopenharmony_ci V("getUTCDay", GetUTCDay, 0, INVALID) \ 624514f5e3Sopenharmony_ci /* Date.prototype.getUTCFullYear ( ) */ \ 634514f5e3Sopenharmony_ci V("getUTCFullYear", GetUTCFullYear, 0, INVALID) \ 644514f5e3Sopenharmony_ci /* Date.prototype.getUTCHours ( ) */ \ 654514f5e3Sopenharmony_ci V("getUTCHours", GetUTCHours, 0, INVALID) \ 664514f5e3Sopenharmony_ci /* Date.prototype.getUTCMilliseconds ( ) */ \ 674514f5e3Sopenharmony_ci V("getUTCMilliseconds", GetUTCMilliseconds, 0, INVALID) \ 684514f5e3Sopenharmony_ci /* Date.prototype.getUTCMinutes ( ) */ \ 694514f5e3Sopenharmony_ci V("getUTCMinutes", GetUTCMinutes, 0, INVALID) \ 704514f5e3Sopenharmony_ci /* Date.prototype.getUTCMonth ( ) */ \ 714514f5e3Sopenharmony_ci V("getUTCMonth", GetUTCMonth, 0, INVALID) \ 724514f5e3Sopenharmony_ci /* Date.prototype.getUTCSeconds ( ) */ \ 734514f5e3Sopenharmony_ci V("getUTCSeconds", GetUTCSeconds, 0, INVALID) \ 744514f5e3Sopenharmony_ci /* Date.prototype.setDate ( date ) */ \ 754514f5e3Sopenharmony_ci V("setDate", SetDate, 1, INVALID) \ 764514f5e3Sopenharmony_ci /* Date.prototype.setFullYear ( year [ , month [ , date ] ] ) */ \ 774514f5e3Sopenharmony_ci V("setFullYear", SetFullYear, 3, INVALID) \ 784514f5e3Sopenharmony_ci /* Date.prototype.setHours ( hour [ , min [ , sec [ , ms ] ] ] ) */ \ 794514f5e3Sopenharmony_ci V("setHours", SetHours, 4, INVALID) \ 804514f5e3Sopenharmony_ci /* Date.prototype.setMilliseconds ( ms ) */ \ 814514f5e3Sopenharmony_ci V("setMilliseconds", SetMilliseconds, 1, INVALID) \ 824514f5e3Sopenharmony_ci /* Date.prototype.setMinutes ( min [ , sec [ , ms ] ] ) */ \ 834514f5e3Sopenharmony_ci V("setMinutes", SetMinutes, 3, INVALID) \ 844514f5e3Sopenharmony_ci /* Date.prototype.setMonth ( month [ , date ] ) */ \ 854514f5e3Sopenharmony_ci V("setMonth", SetMonth, 2, INVALID) \ 864514f5e3Sopenharmony_ci /* Date.prototype.setSeconds ( sec [ , ms ] ) */ \ 874514f5e3Sopenharmony_ci V("setSeconds", SetSeconds, 2, INVALID) \ 884514f5e3Sopenharmony_ci /* Date.prototype.setTime ( time ) */ \ 894514f5e3Sopenharmony_ci V("setTime", SetTime, 1, INVALID) \ 904514f5e3Sopenharmony_ci /* Date.prototype.setUTCDate ( date ) */ \ 914514f5e3Sopenharmony_ci V("setUTCDate", SetUTCDate, 1, INVALID) \ 924514f5e3Sopenharmony_ci /* Date.prototype.setUTCFullYear ( year [ , month [ , date ] ] ) */ \ 934514f5e3Sopenharmony_ci V("setUTCFullYear", SetUTCFullYear, 3, INVALID) \ 944514f5e3Sopenharmony_ci /* Date.prototype.setUTCHours ( hour [ , min [ , sec [ , ms ] ] ] ) */ \ 954514f5e3Sopenharmony_ci V("setUTCHours", SetUTCHours, 4, INVALID) \ 964514f5e3Sopenharmony_ci /* Date.prototype.setUTCMilliseconds ( ms ) */ \ 974514f5e3Sopenharmony_ci V("setUTCMilliseconds", SetUTCMilliseconds, 1, INVALID) \ 984514f5e3Sopenharmony_ci /* Date.prototype.setUTCMinutes ( min [ , sec [ , ms ] ] ) */ \ 994514f5e3Sopenharmony_ci V("setUTCMinutes", SetUTCMinutes, 3, INVALID) \ 1004514f5e3Sopenharmony_ci /* Date.prototype.setUTCMonth ( month [ , date ] ) */ \ 1014514f5e3Sopenharmony_ci V("setUTCMonth", SetUTCMonth, 2, INVALID) \ 1024514f5e3Sopenharmony_ci /* Date.prototype.setUTCSeconds ( sec [ , ms ] ) */ \ 1034514f5e3Sopenharmony_ci V("setUTCSeconds", SetUTCSeconds, 2, INVALID) \ 1044514f5e3Sopenharmony_ci /* Date.prototype.toDateString ( ) */ \ 1054514f5e3Sopenharmony_ci V("toDateString", ToDateString, 0, INVALID) \ 1064514f5e3Sopenharmony_ci /* Date.prototype.toISOString ( ) */ \ 1074514f5e3Sopenharmony_ci V("toISOString", ToISOString, 0, INVALID) \ 1084514f5e3Sopenharmony_ci /* Date.prototype.toJSON ( key ) */ \ 1094514f5e3Sopenharmony_ci V("toJSON", ToJSON, 1, INVALID) \ 1104514f5e3Sopenharmony_ci /* Date.prototype.toLocaleDateString ( [ reserved1 [ , reserved2 ] ] ) */ \ 1114514f5e3Sopenharmony_ci V("toLocaleDateString", ToLocaleDateString, 0, INVALID) \ 1124514f5e3Sopenharmony_ci /* Date.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) */ \ 1134514f5e3Sopenharmony_ci V("toLocaleString", ToLocaleString, 0, INVALID) \ 1144514f5e3Sopenharmony_ci /* Date.prototype.toLocaleTimeString ( [ reserved1 [ , reserved2 ] ] ) */ \ 1154514f5e3Sopenharmony_ci V("toLocaleTimeString", ToLocaleTimeString, 0, INVALID) \ 1164514f5e3Sopenharmony_ci /* Date.prototype.toString ( ) */ \ 1174514f5e3Sopenharmony_ci V("toString", ToString, 0, INVALID) \ 1184514f5e3Sopenharmony_ci /* Date.prototype.toTimeString ( ) */ \ 1194514f5e3Sopenharmony_ci V("toTimeString", ToTimeString, 0, INVALID) \ 1204514f5e3Sopenharmony_ci /* Date.prototype.toUTCString ( ) */ \ 1214514f5e3Sopenharmony_ci V("toUTCString", ToUTCString, 0, INVALID) \ 1224514f5e3Sopenharmony_ci /* Date.prototype.valueOf ( ) */ \ 1234514f5e3Sopenharmony_ci V("valueOf", ValueOf, 0, INVALID) 1244514f5e3Sopenharmony_ci 1254514f5e3Sopenharmony_cinamespace panda::ecmascript::builtins { 1264514f5e3Sopenharmony_ciclass BuiltinsDate : public base::BuiltinsBase { 1274514f5e3Sopenharmony_cipublic: 1284514f5e3Sopenharmony_ci static constexpr int UTC_LENGTH = 7; 1294514f5e3Sopenharmony_ci 1304514f5e3Sopenharmony_ci // 20.4.2 The Date Constructor 1314514f5e3Sopenharmony_ci static JSTaggedValue DateConstructor(EcmaRuntimeCallInfo *argv); 1324514f5e3Sopenharmony_ci 1334514f5e3Sopenharmony_ci // 20.4.3.1 Date.now ( ) 1344514f5e3Sopenharmony_ci static JSTaggedValue Now(EcmaRuntimeCallInfo *argv); 1354514f5e3Sopenharmony_ci 1364514f5e3Sopenharmony_ci // 20.4.3.4 Date.UTC ( year [ , month [ , date [ , hours [ , minutes [ , seconds [ , ms ] ] ] ] ] ] ) 1374514f5e3Sopenharmony_ci static JSTaggedValue UTC(EcmaRuntimeCallInfo *argv); 1384514f5e3Sopenharmony_ci 1394514f5e3Sopenharmony_ci static JSTaggedValue Parse(EcmaRuntimeCallInfo *argv); 1404514f5e3Sopenharmony_ci 1414514f5e3Sopenharmony_ci // 20.4.4.2 Date.prototype.getDate ( ) 1424514f5e3Sopenharmony_ci GET_DATE_VALUE(GetDate, DAYS, true); 1434514f5e3Sopenharmony_ci 1444514f5e3Sopenharmony_ci // 20.4.4.3 Date.prototype.getDay ( ) 1454514f5e3Sopenharmony_ci GET_DATE_VALUE(GetDay, WEEKDAY, true); 1464514f5e3Sopenharmony_ci 1474514f5e3Sopenharmony_ci // 20.4.4.4 Date.prototype.getFullYear ( ) 1484514f5e3Sopenharmony_ci GET_DATE_VALUE(GetFullYear, YEAR, true); 1494514f5e3Sopenharmony_ci 1504514f5e3Sopenharmony_ci // 20.4.4.5 Date.prototype.getHours ( ) 1514514f5e3Sopenharmony_ci GET_DATE_VALUE(GetHours, HOUR, true); 1524514f5e3Sopenharmony_ci 1534514f5e3Sopenharmony_ci // 20.4.4.6 Date.prototype.getMilliseconds ( ) 1544514f5e3Sopenharmony_ci GET_DATE_VALUE(GetMilliseconds, MS, true); 1554514f5e3Sopenharmony_ci 1564514f5e3Sopenharmony_ci // 20.4.4.7 Date.prototype.getMinutes ( ) 1574514f5e3Sopenharmony_ci GET_DATE_VALUE(GetMinutes, MIN, true); 1584514f5e3Sopenharmony_ci 1594514f5e3Sopenharmony_ci // 20.4.4.8 Date.prototype.getMonth ( ) 1604514f5e3Sopenharmony_ci GET_DATE_VALUE(GetMonth, MONTH, true); 1614514f5e3Sopenharmony_ci 1624514f5e3Sopenharmony_ci // 20.4.4.9 Date.prototype.getSeconds ( ) 1634514f5e3Sopenharmony_ci GET_DATE_VALUE(GetSeconds, SEC, true); 1644514f5e3Sopenharmony_ci 1654514f5e3Sopenharmony_ci // 20.4.4.10 Date.prototype.getTime ( ) 1664514f5e3Sopenharmony_ci static JSTaggedValue GetTime(EcmaRuntimeCallInfo *argv); 1674514f5e3Sopenharmony_ci 1684514f5e3Sopenharmony_ci // 20.4.4.11 Date.prototype.getTimezoneOffset ( ) 1694514f5e3Sopenharmony_ci GET_DATE_VALUE(GetTimezoneOffset, TIMEZONE, true); 1704514f5e3Sopenharmony_ci 1714514f5e3Sopenharmony_ci // 20.4.4.12 Date.prototype.getUTCDate ( ) 1724514f5e3Sopenharmony_ci GET_DATE_VALUE(GetUTCDate, DAYS, false); 1734514f5e3Sopenharmony_ci 1744514f5e3Sopenharmony_ci // 20.4.4.13 Date.prototype.getUTCDay ( ) 1754514f5e3Sopenharmony_ci GET_DATE_VALUE(GetUTCDay, WEEKDAY, false); 1764514f5e3Sopenharmony_ci 1774514f5e3Sopenharmony_ci // 20.4.4.14 Date.prototype.getUTCFullYear ( ) 1784514f5e3Sopenharmony_ci GET_DATE_VALUE(GetUTCFullYear, YEAR, false); 1794514f5e3Sopenharmony_ci 1804514f5e3Sopenharmony_ci // 20.4.4.15 Date.prototype.getUTCHours ( ) 1814514f5e3Sopenharmony_ci GET_DATE_VALUE(GetUTCHours, HOUR, false); 1824514f5e3Sopenharmony_ci 1834514f5e3Sopenharmony_ci // 20.4.4.16 Date.prototype.getUTCMilliseconds ( ) 1844514f5e3Sopenharmony_ci GET_DATE_VALUE(GetUTCMilliseconds, MS, false); 1854514f5e3Sopenharmony_ci 1864514f5e3Sopenharmony_ci // 20.4.4.17 Date.prototype.getUTCMinutes ( ) 1874514f5e3Sopenharmony_ci GET_DATE_VALUE(GetUTCMinutes, MIN, false); 1884514f5e3Sopenharmony_ci 1894514f5e3Sopenharmony_ci // 20.4.4.18 Date.prototype.getUTCMonth ( ) 1904514f5e3Sopenharmony_ci GET_DATE_VALUE(GetUTCMonth, MONTH, false); 1914514f5e3Sopenharmony_ci 1924514f5e3Sopenharmony_ci // 20.4.4.19 Date.prototype.getUTCSeconds ( ) 1934514f5e3Sopenharmony_ci GET_DATE_VALUE(GetUTCSeconds, SEC, false); 1944514f5e3Sopenharmony_ci 1954514f5e3Sopenharmony_ci // 20.3.4.20 Date.prototype.setDate ( date ) 1964514f5e3Sopenharmony_ci SET_DATE_VALUE(SetDate, CODE_SET_DATE, true); 1974514f5e3Sopenharmony_ci 1984514f5e3Sopenharmony_ci // 20.3.4.21 Date.prototype.setFullYear ( year [ , month [ , date ] ] ) 1994514f5e3Sopenharmony_ci SET_DATE_VALUE(SetFullYear, CODE_SET_FULL_YEAR, true); 2004514f5e3Sopenharmony_ci 2014514f5e3Sopenharmony_ci // 20.3.4.22 Date.prototype.setHours ( hour [ , min [ , sec [ , ms ] ] ] ) 2024514f5e3Sopenharmony_ci SET_DATE_VALUE(SetHours, CODE_SET_HOURS, true); 2034514f5e3Sopenharmony_ci 2044514f5e3Sopenharmony_ci // 20.3.4.23 Date.prototype.setMilliseconds ( ms ) 2054514f5e3Sopenharmony_ci SET_DATE_VALUE(SetMilliseconds, CODE_SET_MILLISECONDS, true); 2064514f5e3Sopenharmony_ci 2074514f5e3Sopenharmony_ci // 20.3.4.24 Date.prototype.setMinutes ( min [ , sec [ , ms ] ] ) 2084514f5e3Sopenharmony_ci SET_DATE_VALUE(SetMinutes, CODE_SET_MINUTES, true); 2094514f5e3Sopenharmony_ci 2104514f5e3Sopenharmony_ci // 20.3.4.25 Date.prototype.setMonth ( month [ , date ] ) 2114514f5e3Sopenharmony_ci SET_DATE_VALUE(SetMonth, CODE_SET_MONTH, true); 2124514f5e3Sopenharmony_ci 2134514f5e3Sopenharmony_ci // 20.3.4.26 Date.prototype.setSeconds ( sec [ , ms ] ) 2144514f5e3Sopenharmony_ci SET_DATE_VALUE(SetSeconds, CODE_SET_SECONDS, true); 2154514f5e3Sopenharmony_ci 2164514f5e3Sopenharmony_ci // 20.3.4.27 Date.prototype.setTime ( time ) 2174514f5e3Sopenharmony_ci static JSTaggedValue SetTime(EcmaRuntimeCallInfo *argv); 2184514f5e3Sopenharmony_ci 2194514f5e3Sopenharmony_ci // 20.3.4.28 Date.prototype.setUTCDate ( date ) 2204514f5e3Sopenharmony_ci SET_DATE_VALUE(SetUTCDate, CODE_SET_DATE, false); 2214514f5e3Sopenharmony_ci 2224514f5e3Sopenharmony_ci // 20.3.4.29 Date.prototype.setUTCFullYear ( year [ , month [ , date ] ] ) 2234514f5e3Sopenharmony_ci SET_DATE_VALUE(SetUTCFullYear, CODE_SET_FULL_YEAR, false); 2244514f5e3Sopenharmony_ci 2254514f5e3Sopenharmony_ci // 20.3.4.30 Date.prototype.setUTCHours ( hour [ , min [ , sec [ , ms ] ] ] ) 2264514f5e3Sopenharmony_ci SET_DATE_VALUE(SetUTCHours, CODE_SET_HOURS, false); 2274514f5e3Sopenharmony_ci 2284514f5e3Sopenharmony_ci // 20.3.4.31 Date.prototype.setUTCMilliseconds ( ms ) 2294514f5e3Sopenharmony_ci SET_DATE_VALUE(SetUTCMilliseconds, CODE_SET_MILLISECONDS, false); 2304514f5e3Sopenharmony_ci 2314514f5e3Sopenharmony_ci // 20.3.4.32 Date.prototype.setUTCMinutes ( min [ , sec [, ms ] ] ) 2324514f5e3Sopenharmony_ci SET_DATE_VALUE(SetUTCMinutes, CODE_SET_MINUTES, false); 2334514f5e3Sopenharmony_ci 2344514f5e3Sopenharmony_ci // 20.3.4.33 Date.prototype.setUTCMonth ( month [ , date ] ) 2354514f5e3Sopenharmony_ci SET_DATE_VALUE(SetUTCMonth, CODE_SET_MONTH, false); 2364514f5e3Sopenharmony_ci 2374514f5e3Sopenharmony_ci // 20.3.4.34 Date.prototype.setUTCSeconds ( sec [ , ms ] ) 2384514f5e3Sopenharmony_ci SET_DATE_VALUE(SetUTCSeconds, CODE_SET_SECONDS, false); 2394514f5e3Sopenharmony_ci 2404514f5e3Sopenharmony_ci // 20.4.4.35 Date.prototype.toDateString ( ) 2414514f5e3Sopenharmony_ci DATE_STRING(ToDateString); 2424514f5e3Sopenharmony_ci 2434514f5e3Sopenharmony_ci // 20.4.4.36 Date.prototype.toISOString ( ) 2444514f5e3Sopenharmony_ci DATE_TO_STRING(ToISOString); 2454514f5e3Sopenharmony_ci 2464514f5e3Sopenharmony_ci // 20.4.4.37 Date.prototype.toJSON ( key ) 2474514f5e3Sopenharmony_ci static JSTaggedValue ToJSON(EcmaRuntimeCallInfo *argv); 2484514f5e3Sopenharmony_ci 2494514f5e3Sopenharmony_ci // 20.4.4.38 Date.prototype.toLocaleDateString ( [ reserved1 [ , reserved2 ] ] ) 2504514f5e3Sopenharmony_ci static JSTaggedValue ToLocaleDateString(EcmaRuntimeCallInfo *argv); 2514514f5e3Sopenharmony_ci 2524514f5e3Sopenharmony_ci // 20.4.4.39 Date.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) 2534514f5e3Sopenharmony_ci static JSTaggedValue ToLocaleString(EcmaRuntimeCallInfo *argv); 2544514f5e3Sopenharmony_ci 2554514f5e3Sopenharmony_ci // 20.4.4.40 Date.prototype.toLocaleTimeString ( [ reserved1 [ , reserved2 ] ] ) 2564514f5e3Sopenharmony_ci static JSTaggedValue ToLocaleTimeString(EcmaRuntimeCallInfo *argv); 2574514f5e3Sopenharmony_ci 2584514f5e3Sopenharmony_ci // 20.4.4.41 Date.prototype.toString ( ) 2594514f5e3Sopenharmony_ci DATE_STRING(ToString); 2604514f5e3Sopenharmony_ci 2614514f5e3Sopenharmony_ci // 20.4.4.42 Date.prototype.toTimeString ( ) 2624514f5e3Sopenharmony_ci DATE_STRING(ToTimeString); 2634514f5e3Sopenharmony_ci 2644514f5e3Sopenharmony_ci // 20.4.4.43 Date.prototype.toUTCString ( ) 2654514f5e3Sopenharmony_ci DATE_STRING(ToUTCString); 2664514f5e3Sopenharmony_ci 2674514f5e3Sopenharmony_ci // 20.4.4.44 Date.prototype.valueOf ( ) 2684514f5e3Sopenharmony_ci static JSTaggedValue ValueOf(EcmaRuntimeCallInfo *argv); 2694514f5e3Sopenharmony_ci 2704514f5e3Sopenharmony_ci // 20.4.4.45 Date.prototype [ @@toPrimitive ] 2714514f5e3Sopenharmony_ci static JSTaggedValue ToPrimitive(EcmaRuntimeCallInfo *argv); 2724514f5e3Sopenharmony_ci 2734514f5e3Sopenharmony_ci // Excluding the '@@' internal properties 2744514f5e3Sopenharmony_ci static Span<const base::BuiltinFunctionEntry> GetDateFunctions() 2754514f5e3Sopenharmony_ci { 2764514f5e3Sopenharmony_ci return Span<const base::BuiltinFunctionEntry>(DATE_FUNCTIONS); 2774514f5e3Sopenharmony_ci } 2784514f5e3Sopenharmony_ci 2794514f5e3Sopenharmony_ci // Excluding the constructor and '@@' internal properties. 2804514f5e3Sopenharmony_ci static Span<const base::BuiltinFunctionEntry> GetDatePrototypeFunctions() 2814514f5e3Sopenharmony_ci { 2824514f5e3Sopenharmony_ci return Span<const base::BuiltinFunctionEntry>(DATE_PROTOTYPE_FUNCTIONS); 2834514f5e3Sopenharmony_ci } 2844514f5e3Sopenharmony_ci 2854514f5e3Sopenharmony_ci static size_t GetNumPrototypeInlinedProperties() 2864514f5e3Sopenharmony_ci { 2874514f5e3Sopenharmony_ci // 2 : 2 more inline properties in Date.prototype: 2884514f5e3Sopenharmony_ci // (1) Date.prototype.constructor 2894514f5e3Sopenharmony_ci // (2) Date.prototype [ @@toPrimitive ] 2904514f5e3Sopenharmony_ci return GetDatePrototypeFunctions().Size() + 2; 2914514f5e3Sopenharmony_ci } 2924514f5e3Sopenharmony_ci 2934514f5e3Sopenharmony_ciprivate: 2944514f5e3Sopenharmony_ci#define BUILTIN_DATE_FUNCTION_ENTRY(name, func, length, builtinId) \ 2954514f5e3Sopenharmony_ci base::BuiltinFunctionEntry::Create(name, BuiltinsDate::func, length, kungfu::BuiltinsStubCSigns::builtinId), 2964514f5e3Sopenharmony_ci 2974514f5e3Sopenharmony_ci static constexpr std::array DATE_FUNCTIONS = { 2984514f5e3Sopenharmony_ci BUILTIN_DATE_FUNCTIONS(BUILTIN_DATE_FUNCTION_ENTRY) 2994514f5e3Sopenharmony_ci }; 3004514f5e3Sopenharmony_ci static constexpr std::array DATE_PROTOTYPE_FUNCTIONS = { 3014514f5e3Sopenharmony_ci BUILTIN_DATE_PROTOTYPE_FUNCTIONS(BUILTIN_DATE_FUNCTION_ENTRY) 3024514f5e3Sopenharmony_ci }; 3034514f5e3Sopenharmony_ci#undef BUILTIN_DATE_FUNCTION_ENTRY 3044514f5e3Sopenharmony_ci static JSTaggedValue ExtractDateFields(JSThread *thread, uint32_t &length, EcmaRuntimeCallInfo *argv, 3054514f5e3Sopenharmony_ci JSTaggedValue &timeValue); 3064514f5e3Sopenharmony_ci 3074514f5e3Sopenharmony_ci // definition for set data code. 3084514f5e3Sopenharmony_ci static constexpr uint32_t CODE_SET_DATE = 0x32; 3094514f5e3Sopenharmony_ci static constexpr uint32_t CODE_SET_MILLISECONDS = 0x76; 3104514f5e3Sopenharmony_ci static constexpr uint32_t CODE_SET_SECONDS = 0x75; 3114514f5e3Sopenharmony_ci static constexpr uint32_t CODE_SET_MINUTES = 0x74; 3124514f5e3Sopenharmony_ci static constexpr uint32_t CODE_SET_HOURS = 0x73; 3134514f5e3Sopenharmony_ci static constexpr uint32_t CODE_SET_MONTH = 0x31; 3144514f5e3Sopenharmony_ci static constexpr uint32_t CODE_SET_FULL_YEAR = 0x30; 3154514f5e3Sopenharmony_ci static constexpr uint8_t CONSTRUCTOR_MAX_LENGTH = 7; 3164514f5e3Sopenharmony_ci}; 3174514f5e3Sopenharmony_ci} // namespace panda::ecmascript::builtins 3184514f5e3Sopenharmony_ci#endif // ECMASCRIPT_BUILTINS_BUILTINS_DATE_H 319