summaryrefslogtreecommitdiff
path: root/Src/prompt.c
diff options
context:
space:
mode:
authordana <dana@dana.is>2018-06-20 17:29:56 -0500
committerdana <dana@dana.is>2018-06-20 17:29:56 -0500
commit394f3a47e464b67b17e2cb7166df066829250e88 (patch)
tree0fe4262c7857d546878f64b53fc2813e6f59296b /Src/prompt.c
parenteada7e1138a3fca90f085dd764ad86098e58c9ac (diff)
downloadzsh-394f3a47e464b67b17e2cb7166df066829250e88.tar.gz
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.c9
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;
}