aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZsolt Borbély <zsborbely.u-szeged@partner.samsung.com>2018-10-26 20:14:20 +0200
committerAkos Kiss <akiss@inf.u-szeged.hu>2018-10-26 20:14:20 +0200
commitc2b32a83cd50bcc9b739f5c371817ad300e33e0c (patch)
tree8113718120fa53437af6f7fae3f486a40d9f705a
parentc846c4ab73175f65ad1c92254a95cbc0be3b77fc (diff)
Update the webpage (#2573)
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
-rw-r--r--05.PORT-API.md71
-rw-r--r--10.EXT-REFERENCE-HANDLER.md2
2 files changed, 39 insertions, 34 deletions
diff --git a/05.PORT-API.md b/05.PORT-API.md
index 4550ef7c..9dff1ea7 100644
--- a/05.PORT-API.md
+++ b/05.PORT-API.md
@@ -86,27 +86,37 @@ void jerry_port_log (jerry_log_level_t level, const char *fmt, ...);
```c
/**
- * Jerry time zone structure
- */
-typedef struct
-{
- int offset; /**< minutes from west */
- int daylight_saving_time; /**< daylight saving time (1 - DST applies, 0 - not on DST) */
-} jerry_time_zone_t;
-
-/**
- * Get timezone and daylight saving data
+ * Get local time zone adjustment, in milliseconds, for the given timestamp.
+ * The timestamp can be specified in either UTC or local time, depending on
+ * the value of is_utc. Adding the value returned from this function to
+ * a timestamp in UTC time should result in local time for the current time
+ * zone, and subtracting it from a timestamp in local time should result in
+ * UTC time.
+ *
+ * Ideally, this function should satisfy the stipulations applied to LocalTZA
+ * in section 20.3.1.7 of the ECMAScript version 9.0 spec.
+ *
+ * See Also:
+ * ECMA-262 v9, 20.3.1.7
*
* Note:
* This port function is called by jerry-core when
* CONFIG_DISABLE_DATE_BUILTIN is _not_ defined. Otherwise this function is
* not used.
*
- * @param[out] tz_p time zone structure to fill.
- * @return true - if success
- * false - otherwise
+ * @param unix_ms The unix timestamp we want an offset for, given in
+ * millisecond precision (could be now, in the future,
+ * or in the past). As with all unix timestamps, 0 refers to
+ * 1970-01-01, a day is exactly 86 400 000 milliseconds, and
+ * leap seconds cause the same second to occur twice.
+ * @param is_utc Is the given timestamp in UTC time? If false, it is in local
+ * time.
+ *
+ * @return milliseconds between local time and UTC for the given timestamp,
+ * if available
+ *. 0 if not available / we are in UTC.
*/
-bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p);
+double jerry_port_get_local_time_zone_adjustment (double unix_ms, bool is_utc);
/**
* Get system time
@@ -204,31 +214,26 @@ jerry_port_log (jerry_log_level_t level, /**< log level */
## Date
```c
+#include <time.h>
#include <sys/time.h>
#include "jerryscript-port.h"
/**
- * Default implementation of jerry_port_get_time_zone.
+ * Default implementation of jerry_port_get_local_time_zone_adjustment.
*/
-bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p)
+double jerry_port_get_local_time_zone_adjustment (double unix_ms, /**< ms since unix epoch */
+ bool is_utc) /**< is the time above in UTC? */
{
- struct timeval tv;
- struct timezone tz;
-
- /* gettimeofday may not fill tz, so zero-initializing */
- tz.tz_minuteswest = 0;
- tz.tz_dsttime = 0;
-
- if (gettimeofday (&tv, &tz) != 0)
+ struct tm tm;
+ time_t now = (time_t) (unix_ms / 1000);
+ localtime_r (&now, &tm);
+ if (!is_utc)
{
- return false;
+ now -= tm.tm_gmtoff;
+ localtime_r (&now, &tm);
}
-
- tz_p->offset = tz.tz_minuteswest;
- tz_p->daylight_saving_time = tz.tz_dsttime > 0 ? 1 : 0;
-
- return true;
-} /* jerry_port_get_time_zone */
+ return ((double) tm.tm_gmtoff) * 1000;
+} /* jerry_port_get_local_time_zone_adjustment */
/**
* Default implementation of jerry_port_get_current_time.
@@ -262,10 +267,10 @@ static jerry_context_t *current_context_p = NULL;
* Set the current_context_p as the passed pointer.
*/
void
-jerry_port_default_set_context (jerry_context_t *context_p) /**< points to the created context */
+jerry_port_default_set_current_context (jerry_context_t *context_p) /**< points to the created context */
{
current_context_p = context_p;
-} /* jerry_port_default_set_context */
+} /* jerry_port_default_set_current_context */
/**
* Get the current context.
diff --git a/10.EXT-REFERENCE-HANDLER.md b/10.EXT-REFERENCE-HANDLER.md
index b6cfdd6b..f0020008 100644
--- a/10.EXT-REFERENCE-HANDLER.md
+++ b/10.EXT-REFERENCE-HANDLER.md
@@ -63,7 +63,7 @@ jerryx_handler_assert_throw (const jerry_value_t func_obj_val, const jerry_value
- [jerryx_handler_register_global](#jerryx_handler_register_global)
-## jerryx_handler_assert_fatal
+## jerryx_handler_assert
**Summary**