This patch makes it possible to use the %N conversion specification
to output nanoseconds, similarly to some other date(1) implementations.
Details
- Reviewers
- None
- Group Reviewers
manpages
- build the world with the patched libc
- run date +%N
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 42516 Build 39404: arc lint + arc unit
Event Timeline
lib/libc/stdtime/strftime.c | ||
---|---|---|
298 | I'm not sure if that's the right clock to use. |
This is something quite weird. strftime(3) prints its argument (struct tm), in various formats. Your patch adds printing for the current time.
Which other implementations do that?
Ha, good catch. There are no such implementations I guess. I'll take a look at the function once again.
I took another look at the problem and it looks like modifying strftime to support %N for nanoseconds is not easy. The reason is that the interface has only second precision (via struct tm). In theory, we could extend struct tm to include nanoseconds but it is not something other libc implementations are doing / document. Also, adding additional fields to struct tm (documented in ctime(3)) sounds like a bad idea to me as it seems quite intrusive.
My ultimate goal is to add support for nanoseconds to date(1). Perhaps there is another way to implement this feature.