Question: How to handle Date object in native C? #4058
Closed
Description
Hi, I'm having hard time to figure out how to get the Date.year, month, date in the native C code. Also having hard time to figure out how to return a Date object from native to javascript. Thanks
Javascript
let date = native_driver_gui_calendar.setTodayDate(new Date(2020, 6, 10));
Native C
static jerry_value_t function_native_driver_gui_calendar_setTodayDate(const jerry_value_t func_value, /**< function object */
const jerry_value_t this_value, /**< this arg */
const jerry_value_t args[], /**< function arguments */
const jerry_length_t args_cnt) /**< number of function arguments */
{
//How to get the year, month, date of a Date object?
//The following code returns all zero
printf("Year:%d Month:%d Day:%d\n", ecma_date_year_from_time(args[0]), ecma_date_month_from_time(args[0]), ecma_date_date_from_time(args[0]));
//How to return "new Date(2020, 0,0)" value to the javascript?
return jerry_create_date();
}