File tree 4 files changed +12
-13
lines changed
4 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -451,7 +451,7 @@ public final class IndexStoreDB {
451
451
}
452
452
453
453
/// Returns the latest modification date of a unit that contains the given source file.
454
- ///
454
+ ///
455
455
/// If no unit containing the given source file exists, returns `nil`.
456
456
public func dateOfLatestUnitFor( filePath: String ) -> Date ? {
457
457
let timestamp = filePath. withCString { filePathCString in
@@ -460,7 +460,7 @@ public final class IndexStoreDB {
460
460
if timestamp == 0 {
461
461
return nil
462
462
}
463
- return Date ( timeIntervalSince1970: timestamp)
463
+ return Date ( timeIntervalSince1970: Double ( timestamp) / 1_000_000_000 )
464
464
}
465
465
}
466
466
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ extension SymbolLocation: CustomStringConvertible {
51
51
extension SymbolLocation {
52
52
internal init ( _ loc: indexstoredb_symbol_location_t ) {
53
53
path = String ( cString: indexstoredb_symbol_location_path ( loc) )
54
- timestamp = Date ( timeIntervalSince1970: indexstoredb_symbol_location_timestamp ( loc) )
54
+ timestamp = Date ( timeIntervalSince1970: Double ( indexstoredb_symbol_location_timestamp ( loc) ) / 1_000_000_000 )
55
55
moduleName = String ( cString: indexstoredb_symbol_location_module_name ( loc) )
56
56
isSystem = indexstoredb_symbol_location_is_system ( loc)
57
57
line = Int ( indexstoredb_symbol_location_line ( loc) )
Original file line number Diff line number Diff line change @@ -320,7 +320,7 @@ indexstoredb_index_related_symbol_occurrences_by_usr(
320
320
_Nonnull indexstoredb_symbol_occurrence_receiver_t );
321
321
322
322
/// Iterates over all the symbols contained in \p path
323
- ///
323
+ ///
324
324
/// The symbol passed to the receiver is only valid for the duration of the
325
325
/// receiver call.
326
326
INDEXSTOREDB_PUBLIC bool
@@ -375,10 +375,10 @@ INDEXSTOREDB_PUBLIC
375
375
const char * _Nonnull
376
376
indexstoredb_symbol_location_path (_Nonnull indexstoredb_symbol_location_t );
377
377
378
- /// Returns a Unix timestamp (seconds since 1/1/1970) at which the unit file that contains a symbol has last been
378
+ /// Returns a Unix timestamp (nanoseconds since 1/1/1970) at which the unit file that contains a symbol has last been
379
379
/// modified.
380
380
INDEXSTOREDB_PUBLIC
381
- double
381
+ uint64_t
382
382
indexstoredb_symbol_location_timestamp (_Nonnull indexstoredb_symbol_location_t loc );
383
383
384
384
/// Returns the module name of the given symbol location.
@@ -577,10 +577,10 @@ indexstoredb_index_unit_tests(
577
577
_Nonnull indexstoredb_symbol_occurrence_receiver_t receiver
578
578
);
579
579
580
- /// Returns a Unix timestamp (seconds since 1/1/1970) of the latest unit that contains the given source file.
581
- ///
580
+ /// Returns a Unix timestamp (nanoseconds since 1/1/1970) of the latest unit that contains the given source file.
581
+ ///
582
582
/// If no unit containing the given source file exists, returns 0.
583
- INDEXSTOREDB_PUBLIC double
583
+ INDEXSTOREDB_PUBLIC uint64_t
584
584
indexstoredb_timestamp_of_latest_unit_for_file (
585
585
_Nonnull indexstoredb_index_t index ,
586
586
const char * _Nonnull fileName
Original file line number Diff line number Diff line change @@ -445,15 +445,14 @@ indexstoredb_symbol_location_path(indexstoredb_symbol_location_t loc) {
445
445
return obj->getPath ().getPathString ().c_str ();
446
446
}
447
447
448
- double
448
+ uint64_t
449
449
indexstoredb_symbol_location_timestamp (indexstoredb_symbol_location_t loc) {
450
450
auto obj = (SymbolLocation *)loc;
451
451
// Up until C++20 the reference date of time_since_epoch is undefined but according to
452
452
// https://en.cppreference.com/w/cpp/chrono/system_clock most implementations use Unix Time.
453
453
// Since C++20, system_clock is defined to measure time since 1/1/1970.
454
454
// We rely on `time_since_epoch` always returning the nanoseconds since 1/1/1970.
455
- auto nanosecondsSinceEpoch = obj->getPath ().getModificationTime ().time_since_epoch ().count ();
456
- return static_cast <double >(nanosecondsSinceEpoch) / 1000 / 1000 / 1000 ;
455
+ return obj->getPath ().getModificationTime ().time_since_epoch ().count ();
457
456
}
458
457
459
458
const char *
@@ -668,7 +667,7 @@ indexstoredb_index_unit_tests(
668
667
});
669
668
}
670
669
671
- INDEXSTOREDB_PUBLIC double
670
+ INDEXSTOREDB_PUBLIC uint64_t
672
671
indexstoredb_timestamp_of_latest_unit_for_file (
673
672
_Nonnull indexstoredb_index_t index,
674
673
const char *_Nonnull fileName
You can’t perform that action at this time.
0 commit comments