| 166 | } |
| 167 | |
| 168 | double Time::ToJsTime() const { |
| 169 | if (is_null()) { |
| 170 | // Preserve 0 so the invalid result doesn't depend on the platform. |
| 171 | return 0; |
| 172 | } |
| 173 | if (is_max()) { |
| 174 | // Preserve max without offset to prevent overflow. |
| 175 | return std::numeric_limits<double>::infinity(); |
| 176 | } |
| 177 | return (static_cast<double>(us_ - kTimeTToMicrosecondsOffset) / |
| 178 | kMicrosecondsPerMillisecond); |
| 179 | } |
| 180 | |
| 181 | int64_t Time::ToJavaTime() const { |
| 182 | if (is_null()) { |