(property, object, callback, properties, whitespace, indentation, stack)
| 7294 | // Internal: Recursively serializes an object. Implements the |
| 7295 | // `Str(key, holder)`, `JO(value)`, and `JA(value)` operations. |
| 7296 | var serialize = function(property, object, callback, properties, whitespace, indentation, stack) { |
| 7297 | var value, |
| 7298 | className, |
| 7299 | year, |
| 7300 | month, |
| 7301 | date, |
| 7302 | time, |
| 7303 | hours, |
| 7304 | minutes, |
| 7305 | seconds, |
| 7306 | milliseconds, |
| 7307 | results, |
| 7308 | element, |
| 7309 | index, |
| 7310 | length, |
| 7311 | prefix, |
| 7312 | result; |
| 7313 | try { |
| 7314 | // Necessary for host object support. |
| 7315 | value = object[property]; |
| 7316 | } catch (exception) {} |
| 7317 | if (typeof value == "object" && value) { |
| 7318 | className = getClass.call(value); |
| 7319 | if (className == dateClass && !isProperty.call(value, "toJSON")) { |
| 7320 | if (value > -1 / 0 && value < 1 / 0) { |
| 7321 | // Dates are serialized according to the `Date#toJSON` method |
| 7322 | // specified in ES 5.1 section 15.9.5.44. See section 15.9.1.15 |
| 7323 | // for the ISO 8601 date time string format. |
| 7324 | if (getDay) { |
| 7325 | // Manually compute the year, month, date, hours, minutes, |
| 7326 | // seconds, and milliseconds if the `getUTC*` methods are |
| 7327 | // buggy. Adapted from @Yaffle's `date-shim` project. |
| 7328 | date = floor(value / 864e5); |
| 7329 | for (year = floor(date / 365.2425) + 1970 - 1; getDay(year + 1, 0) <= date; year++) |
| 7330 | ; |
| 7331 | for (month = floor((date - getDay(year, 0)) / 30.42); getDay(year, month + 1) <= date; month++) |
| 7332 | ; |
| 7333 | date = 1 + date - getDay(year, month); |
| 7334 | // The `time` value specifies the time within the day (see ES |
| 7335 | // 5.1 section 15.9.1.2). The formula `(A % B + B) % B` is used |
| 7336 | // to compute `A modulo B`, as the `%` operator does not |
| 7337 | // correspond to the `modulo` operation for negative numbers. |
| 7338 | time = (value % 864e5 + 864e5) % 864e5; |
| 7339 | // The hours, minutes, seconds, and milliseconds are obtained by |
| 7340 | // decomposing the time within the day. See section 15.9.1.10. |
| 7341 | hours = floor(time / 36e5) % 24; |
| 7342 | minutes = floor(time / 6e4) % 60; |
| 7343 | seconds = floor(time / 1e3) % 60; |
| 7344 | milliseconds = time % 1e3; |
| 7345 | } else { |
| 7346 | year = value.getUTCFullYear(); |
| 7347 | month = value.getUTCMonth(); |
| 7348 | date = value.getUTCDate(); |
| 7349 | hours = value.getUTCHours(); |
| 7350 | minutes = value.getUTCMinutes(); |
| 7351 | seconds = value.getUTCSeconds(); |
| 7352 | milliseconds = value.getUTCMilliseconds(); |
| 7353 | } |
no test coverage detected