Change current time from uint64_t to double in Date Port API
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
@@ -447,7 +447,7 @@ ecma_builtin_date_now (ecma_value_t this_arg __attr_unused___) /**< this argumen
|
|||||||
{
|
{
|
||||||
ecma_number_t *now_num_p = ecma_alloc_number ();
|
ecma_number_t *now_num_p = ecma_alloc_number ();
|
||||||
|
|
||||||
*now_num_p = (ecma_number_t) jerry_port_get_current_time ();
|
*now_num_p = DOUBLE_TO_ECMA_NUMBER_T (jerry_port_get_current_time ());
|
||||||
|
|
||||||
return ecma_make_number_value (now_num_p);
|
return ecma_make_number_value (now_num_p);
|
||||||
} /* ecma_builtin_date_now */
|
} /* ecma_builtin_date_now */
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#define JERRY_PORT_H
|
#define JERRY_PORT_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -99,7 +98,7 @@ bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p);
|
|||||||
*
|
*
|
||||||
* @return milliseconds since Unix epoch
|
* @return milliseconds since Unix epoch
|
||||||
*/
|
*/
|
||||||
uint64_t jerry_port_get_current_time (void);
|
double jerry_port_get_current_time (void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
|
|||||||
@@ -43,11 +43,11 @@ bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p)
|
|||||||
/**
|
/**
|
||||||
* Default implementation of jerry_port_get_current_time.
|
* Default implementation of jerry_port_get_current_time.
|
||||||
*/
|
*/
|
||||||
uint64_t jerry_port_get_current_time ()
|
double jerry_port_get_current_time ()
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
gettimeofday (&tv, NULL);
|
gettimeofday (&tv, NULL);
|
||||||
|
|
||||||
return ((uint64_t) tv.tv_sec) * 1000 + ((uint64_t) tv.tv_usec) / 1000;
|
return ((double) tv.tv_sec) * 1000.0 + ((double) tv.tv_usec) / 1000.0;
|
||||||
} /* jerry_port_get_current_time */
|
} /* jerry_port_get_current_time */
|
||||||
|
|||||||
Reference in New Issue
Block a user