1111//===----------------------------------------------------------------------===//
1212import TSCBasic
1313import struct Foundation. Data
14- import struct Foundation. Date
1514import struct Foundation. TimeInterval
1615import class Dispatch. DispatchQueue
1716#if canImport(Darwin)
@@ -740,16 +739,16 @@ extension TSCBasic.FileSystem {
740739 /// - Parameter file: The path to a file.
741740 /// - Throws: `SystemError` if the underlying `stat` operation fails.
742741 /// - Returns: A `Date` value containing the last modification time.
743- public func lastModificationTime( for file: VirtualPath ) throws -> Date {
742+ public func lastModificationTime( for file: VirtualPath ) throws -> TimePoint {
744743 try resolvingVirtualPath ( file) { path in
745744 #if canImport(Darwin)
746745 var s = Darwin . stat ( )
747746 let err = stat ( path. pathString, & s)
748747 guard err == 0 else {
749748 throw SystemError . stat ( errno, path. pathString)
750749 }
751- let ti = ( TimeInterval ( s. st_mtimespec. tv_sec) - kCFAbsoluteTimeIntervalSince1970 ) + ( 1.0e-9 * TimeInterval ( s . st_mtimespec . tv_nsec ) )
752- return Date ( timeIntervalSinceReferenceDate : ti )
750+ return TimePoint ( seconds : UInt64 ( s. st_mtimespec. tv_sec) ,
751+ nanoseconds : UInt32 ( s . st_mtimespec . tv_nsec ) )
753752 #else
754753 // `getFileInfo` is going to ask Foundation to stat this path, and
755754 // Foundation is always going to use `lstat` to do so. This is going to
@@ -758,7 +757,8 @@ extension TSCBasic.FileSystem {
758757 // that regenerate lots of symlinks but do not otherwise alter the
759758 // contents of files - like Bazel - quite happy.
760759 let path = resolveSymlinks ( path)
761- return try localFileSystem. getFileInfo ( path) . modTime
760+ let interval = try localFileSystem. getFileInfo ( path) . modTime. timeIntervalSince1970
761+ return TimePoint ( seconds: UInt64 ( interval. rounded ( . down) ) , nanoseconds: 0 )
762762 #endif
763763 }
764764 }
0 commit comments