Skip to content

Commit e73e883

Browse files
committed
Return timestamp of latest unit for file in seconds not nanoseconds
The doc comment said that the timestamp was in seconds, but we were returning a timestamp in nanoseconds.
1 parent 2adc599 commit e73e883

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/CIndexStoreDB/CIndexStoreDB.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ indexstoredb_symbol_location_path(indexstoredb_symbol_location_t loc) {
448448
double
449449
indexstoredb_symbol_location_timestamp(indexstoredb_symbol_location_t loc) {
450450
auto obj = (SymbolLocation *)loc;
451-
// Up until C++20 the reference date of time_since_epoch is undefined but according to
451+
// Up until C++20 the reference date of time_since_epoch is undefined but according to
452452
// https://en.cppreference.com/w/cpp/chrono/system_clock most implementations use Unix Time.
453453
// Since C++20, system_clock is defined to measure time since 1/1/1970.
454454
// We rely on `time_since_epoch` always returning the nanoseconds since 1/1/1970.
@@ -676,13 +676,14 @@ indexstoredb_timestamp_of_latest_unit_for_file(
676676
auto obj = (Object<std::shared_ptr<IndexSystem>> *)index;
677677
llvm::Optional<llvm::sys::TimePoint<>> timePoint = obj->value->timestampOfLatestUnitForFile(fileName);
678678
if (timePoint) {
679-
// Up until C++20 the reference date of time_since_epoch is undefined but according to
679+
// Up until C++20 the reference date of time_since_epoch is undefined but according to
680680
// https://en.cppreference.com/w/cpp/chrono/system_clock most implementations use Unix Time.
681681
// Since C++20, system_clock is defined to measure time since 1/1/1970.
682682
// We rely on `time_since_epoch` always returning the nanoseconds since 1/1/1970.
683-
return timePoint->time_since_epoch().count();
683+
auto nanosecondsSinceEpoch = timePoint->time_since_epoch().count();
684+
return static_cast<double>(nanosecondsSinceEpoch) / 1000 / 1000 / 1000;
684685
}
685686
return 0;
686-
}
687+
}
687688

688689
ObjectBase::~ObjectBase() {}

0 commit comments

Comments
 (0)