You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preserve nanosecond precision in filesystem timestamps #10674
While porting VirtualFileSystem into Effect, I needed to preserve file access and modification times when capturing and restoring a filesystem. The draft in #9960 has a concrete use for this where preserveTimes option accepts atime and mtime with nanosecond precision.
For example, if a file's mtime is 1_000_000_001n nanoseconds since the Unix epoch, converting it to a JavaScript Date gives 1_000 milliseconds. Restoring from that value gives 1_000_000_000n. The restored file has a different modification time even though its contents never changed.
What is the feature you are proposing to solve the problem?
I'd like VirtualFileSystem to round-trip those timestamps exactly, including times before the Unix epoch. When a caller needs a Date or DateTime.Utc, it should be explicit what happens if the timestamp falls outside the supported range or if conversion would discard part of a millisecond.
The review of #9870 suggested starting with a filesystem call site to decide how much of this belongs in DateTime. @fubhy also raised Protobuf timestamps as a possible second use. Would a shared epoch-nanosecond type help both, or is a filesystem-local type enough for #9960?
What alternatives have you considered?
In #9870 I used DateTime.UnixNano, a branded bigint for signed nanoseconds since the Unix epoch. Its checked conversions report precision loss by default and let callers explicitly truncate toward zero. That's one implementation we can reuse if a shared type makes sense.
A smaller option is to keep epoch nanoseconds as a bigint in VirtualFileSystem and convert only where an API needs milliseconds. I'm moving this here so I can close #9870 while keeping the timestamp requirement for #9960 on record.
Activity