ref: f0ea8a3f6019b4fe7d37f33b0a5a3a88fd1fcdc7
parent: 665acf7db5ff62e5a53e6e4a2d84f470cfeeba4f
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Mon Jun 3 19:49:06 EDT 2013
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.
--- a/sys/src/cmd/test.c
+++ b/sys/src/cmd/test.c
@@ -338,11 +338,13 @@
/* 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 @@
}
}
- r = dir->mtime + n < time(0);
+ if (r != 0)
+ n = time(0) - n;
+ r = dir->mtime < n;
free(dir);
return r;
}
--
⑨