File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Sources/SwiftDriver/Utilities Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -754,7 +754,24 @@ extension TSCBasic.FileSystem {
754754 // that regenerate lots of symlinks but do not otherwise alter the
755755 // contents of files - like Bazel - quite happy.
756756 let path = resolveSymlinks ( path)
757- let interval = try localFileSystem. getFileInfo ( path) . modTime. timeIntervalSince1970
757+ #if os(Windows)
758+ // The NT epoch is 1601, so we need to add a correction factor to bridge
759+ // between Foundation.Date's insistence on using the Mac epoch time of
760+ // 2001 as its reference date.
761+ //
762+ // This factor is a coarse approximation of the difference between
763+ // (Jan 1, 1970 at midnight GMT) and (Jan 1, 1601 at midnight GMT).
764+ //
765+ // DO NOT RELY ON THIS VALUE
766+ //
767+ // This whole thing needs to be replaced by APIs that traffic in values
768+ // derived from uncorrected Windows clocks.
769+ let correction : TimeInterval = 11_644_473_600.0
770+ let unixReferenceDate = try localFileSystem. getFileInfo ( path) . modTime. timeIntervalSince1970
771+ let interval : TimeInterval = unixReferenceDate + correction
772+ #else
773+ let interval : TimeInterval = try localFileSystem. getFileInfo ( path) . modTime. timeIntervalSince1970
774+ #endif
758775 return TimePoint ( seconds: UInt64 ( interval. rounded ( . down) ) , nanoseconds: 0 )
759776 #endif
760777 }
You can’t perform that action at this time.
0 commit comments