| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/date.h" | 8 #include "src/date.h" |
| 9 #include "src/dateparser-inl.h" | 9 #include "src/dateparser-inl.h" |
| 10 #include "src/messages.h" | 10 #include "src/messages.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 RUNTIME_FUNCTION(Runtime_DateCurrentTime) { | 71 RUNTIME_FUNCTION(Runtime_DateCurrentTime) { |
| 72 HandleScope scope(isolate); | 72 HandleScope scope(isolate); |
| 73 DCHECK(args.length() == 0); | 73 DCHECK(args.length() == 0); |
| 74 if (FLAG_log_timer_events || FLAG_prof_cpp) LOG(isolate, CurrentTimeEvent()); | 74 if (FLAG_log_timer_events || FLAG_prof_cpp) LOG(isolate, CurrentTimeEvent()); |
| 75 | 75 |
| 76 // According to ECMA-262, section 15.9.1, page 117, the precision of | 76 // According to ECMA-262, section 15.9.1, page 117, the precision of |
| 77 // the number in a Date object representing a particular instant in | 77 // the number in a Date object representing a particular instant in |
| 78 // time is milliseconds. Therefore, we floor the result of getting | 78 // time is milliseconds. Therefore, we floor the result of getting |
| 79 // the OS time. | 79 // the OS time. |
| 80 double millis; | 80 double millis; |
| 81 if (FLAG_verify_predictable) { | 81 if (FLAG_fixed_date > 0) { |
| 82 millis = 1388534400000.0; // Jan 1 2014 00:00:00 GMT+0000 |
| 83 millis += 1000.0 * FLAG_fixed_date; |
| 84 } else if (FLAG_verify_predictable) { |
| 82 millis = 1388534400000.0; // Jan 1 2014 00:00:00 GMT+0000 | 85 millis = 1388534400000.0; // Jan 1 2014 00:00:00 GMT+0000 |
| 83 millis += Floor(isolate->heap()->synthetic_time()); | 86 millis += Floor(isolate->heap()->synthetic_time()); |
| 84 } else { | 87 } else { |
| 85 millis = Floor(base::OS::TimeCurrentMillis()); | 88 millis = Floor(base::OS::TimeCurrentMillis()); |
| 86 } | 89 } |
| 87 return *isolate->factory()->NewNumber(millis); | 90 return *isolate->factory()->NewNumber(millis); |
| 88 } | 91 } |
| 89 | 92 |
| 90 | 93 |
| 91 RUNTIME_FUNCTION(Runtime_DateParseString) { | 94 RUNTIME_FUNCTION(Runtime_DateParseString) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 HandleScope scope(isolate); | 184 HandleScope scope(isolate); |
| 182 THROW_NEW_ERROR_RETURN_FAILURE( | 185 THROW_NEW_ERROR_RETURN_FAILURE( |
| 183 isolate, NewTypeError(MessageTemplate::kNotDateObject)); | 186 isolate, NewTypeError(MessageTemplate::kNotDateObject)); |
| 184 } | 187 } |
| 185 JSDate* date = JSDate::cast(obj); | 188 JSDate* date = JSDate::cast(obj); |
| 186 if (index == 0) return date->value(); | 189 if (index == 0) return date->value(); |
| 187 return JSDate::GetField(date, Smi::FromInt(index)); | 190 return JSDate::GetField(date, Smi::FromInt(index)); |
| 188 } | 191 } |
| 189 } // namespace internal | 192 } // namespace internal |
| 190 } // namespace v8 | 193 } // namespace v8 |
| OLD | NEW |