MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

move to Date object slot for timestamp

+7 -14
+7 -14
src/ant.c
··· 1585 1585 } 1586 1586 1587 1587 static size_t strdate(struct js *js, jsval_t obj, char *buf, size_t len) { 1588 - jsoff_t time_off = lkp(js, obj, "__time", 6); 1589 - if (time_off == 0) return cpy(buf, len, "Invalid Date", 12); 1590 - 1591 - jsval_t time_val = resolveprop(js, mkval(T_PROP, time_off)); 1588 + jsval_t time_val = js_get_slot(js, obj, SLOT_DATA); 1592 1589 if (vtype(time_val) != T_NUM) return cpy(buf, len, "Invalid Date", 12); 1593 1590 1594 1591 double timestamp_ms = tod(time_val); ··· 1690 1687 1691 1688 // todo: split into smaller functions 1692 1689 static size_t strobj(struct js *js, jsval_t obj, char *buf, size_t len) { 1693 - jsoff_t time_off = lkp(js, obj, "__time", 6); 1694 - if (time_off != 0) return strdate(js, obj, buf, len); 1690 + jsval_t obj_proto = js_get_proto(js, obj); 1691 + jsval_t date_proto = js_get_ctor_proto(js, "Date", 4); 1692 + if (obj_proto == date_proto) return strdate(js, obj, buf, len); 1695 1693 1696 1694 int ref = get_circular_ref(obj); 1697 1695 if (ref) return ref > 0 ? (size_t) snprintf(buf, len, "[Circular *%d]", ref) : cpy(buf, len, "[Circular]", 10); ··· 12950 12948 timestamp_ms = (double)t * 1000.0 + ms; 12951 12949 } 12952 12950 12953 - jsval_t time_key = js_mkstr(js, "__time", 6); 12954 - jsval_t time_val = tov(timestamp_ms); 12955 - setprop(js, date_obj, time_key, time_val); 12951 + js_set_slot(js, date_obj, SLOT_DATA, tov(timestamp_ms)); 12956 12952 12957 12953 return date_obj; 12958 12954 } ··· 12996 12992 } 12997 12993 12998 12994 static double date_get_time(struct js *js, jsval_t this_val) { 12999 - jsoff_t time_off = lkp(js, this_val, "__time", 6); 13000 - if (time_off == 0) return NAN; 13001 - jsval_t time_val = resolveprop(js, mkval(T_PROP, time_off)); 12995 + jsval_t time_val = js_get_slot(js, this_val, SLOT_DATA); 13002 12996 if (vtype(time_val) != T_NUM) return NAN; 13003 12997 return tod(time_val); 13004 12998 } ··· 13216 13210 13217 13211 static void date_set_time(struct js *js, jsval_t date, double ms) { 13218 13212 if (vtype(date) != T_OBJ) return; 13219 - jsval_t time_key = js_mkstr(js, "__time", 6); 13220 - setprop(js, date, time_key, tov(ms)); 13213 + js_set_slot(js, date, SLOT_DATA, tov(ms)); 13221 13214 } 13222 13215 13223 13216 static jsval_t builtin_Date_setTime(struct js *js, jsval_t *args, int nargs) {