diff options
author | dana <dana@dana.is> | 2018-06-20 17:29:56 -0500 |
---|---|---|
committer | dana <dana@dana.is> | 2018-06-20 17:29:56 -0500 |
commit | 394f3a47e464b67b17e2cb7166df066829250e88 (patch) | |
tree | 0fe4262c7857d546878f64b53fc2813e6f59296b /Src/prompt.c | |
parent | eada7e1138a3fca90f085dd764ad86098e58c9ac (diff) | |
download | zsh-394f3a47e464b67b17e2cb7166df066829250e88.tar.gz zsh-394f3a47e464b67b17e2cb7166df066829250e88.tar.xz zsh-394f3a47e464b67b17e2cb7166df066829250e88.zip |
43075: Support nanosecond-precision time formatting
* Teach ztrftime() %9. and %N for nanoseconds * Update prompt expansion to pass sub-second times for time formatting * Update zsh/stat to pass sub-second times for atime/mtime/ctime Patch heavily based on Oliver's earlier work @ workers/24059
Diffstat (limited to 'Src/prompt.c')
-rw-r--r-- | Src/prompt.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Src/prompt.c b/Src/prompt.c index 95da52559..959ed8e3d 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -273,8 +273,7 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) char *ss, *hostnam; int t0, arg, test, sep, j, numjobs, len; struct tm *tm; - struct timezone dummy_tz; - struct timeval tv; + struct timespec ts; time_t timet; Nameddir nd; @@ -664,8 +663,8 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) tmfmt = "%l:%M%p"; break; } - gettimeofday(&tv, &dummy_tz); - tm = localtime(&tv.tv_sec); + zgettime(&ts); + tm = localtime(&ts.tv_sec); /* * Hack because strftime won't say how * much space it actually needs. Try to add it @@ -675,7 +674,7 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) */ for(j = 0, t0 = strlen(tmfmt)*8; j < 3; j++, t0*=2) { addbufspc(t0); - if ((len = ztrftime(bv->bp, t0, tmfmt, tm, tv.tv_usec)) + if ((len = ztrftime(bv->bp, t0, tmfmt, tm, ts.tv_nsec)) >= 0) break; } |