ref: bc9df6c60c7d2346aa89674b3b7ba26b5d3e97ad
parent: b099f734b6af48a6f5e8b8cefb9fe75bc0d0cdaf
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;
}
--
⑨