Hi Jay,
The right way to represent a timestamp in Cap'n Proto is as a 64-bit number counting seconds, milliseconds, microseconds, or nanoseconds since Jan 1, 1970. I usually write something like:
using TimePointInNs = UInt64;
# Nanoseconds since the epoch.
struct Foo {
timestamp @0 :TimePointInNs;
}
I think using any other representation for dates would go against the Cap'n Proto philosophy, since a simple integer counting seconds is the most convenient format for computation, and Cap'n Proto is all about optimizing for computation.
With that said, I can see an argument that the stringification code should be extended to recognize timestamps in some way for display purposes. There are a few ways this could be accomplished:
1) Define a standard struct type wrapping a timestamp, and special-case that in the stringification code. Unfortunately, in the absence of inline structs, this would have a pointer's worth of overhead for every timestamp.
2) Define a standard annotation to mark timestamps, and use that. Kind of ugly.
3) Define a custom type which is equivalent to Int64 but can be recognized by the stringification code. This would likely be far more intrusive than it is worth, so I don't recommend it.
I'm not particularly fond of any of these options. #1 is the most elegant but has unacceptable overhead. Perhaps if we eventually re-add inline structs to the language (they existed once, but were eliminated due to complexity) then #1 will make sense.
-Kenton