diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-06-03 23:49:06 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-06-03 23:49:06 +0200 |
commit | bc9df6c60c7d2346aa89674b3b7ba26b5d3e97ad (patch) | |
tree | 602a063d101be43567da1080794a11603b2a7afa /sys/src/cmd/test.c | |
parent | b099f734b6af48a6f5e8b8cefb9fe75bc0d0cdaf (diff) |
time: fix -older t for relative times to current time (thanks arisawa for pointing out)
from test(1):
f -older t True if file f is older than (modified before)
time t. If t is a integer followed by the letters
y(years), M(months), d(days), h(hours),
m(minutes), or s(seconds), it represents current
time minus the specified time. If there is no
letter, it represents seconds since epoch. You
can also concatenate mixed units. For example,
3d12h means three days and twelve hours ago.
this means *without* [y M d h m s] unit, t is *absolute* time
in seconds since epoch.
Diffstat (limited to 'sys/src/cmd/test.c')
-rw-r--r-- | sys/src/cmd/test.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/src/cmd/test.c b/sys/src/cmd/test.c index 42318075d..52ff667df 100644 --- a/sys/src/cmd/test.c +++ b/sys/src/cmd/test.c @@ -338,11 +338,13 @@ isolder(char *pin, char *f) /* parse time */ n = 0; + r = 1; while(*p){ m = strtoul(p, &p, 0); switch(*p){ case 0: n = m; + r = 0; break; case 'y': m *= 12; @@ -368,7 +370,9 @@ isolder(char *pin, char *f) } } - r = dir->mtime + n < time(0); + if (r != 0) + n = time(0) - n; + r = dir->mtime < n; free(dir); return r; } |