DragonFly commits List (threaded) for 2008-01
DragonFly BSD
DragonFly commits List (threaded) for 2008-01
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: cvs commit: src/sbin/hammer cache.c cmd_show.c


From: YONETANI Tomokazu <qhwt+dfly@xxxxxxxxxx>
Date: Fri, 18 Jan 2008 20:16:13 +0900

On Wed, Jan 16, 2008 at 09:14:49PM -0800, Matthew Dillon wrote:
> dillon      2008/01/16 21:14:49 PST
> 
> DragonFly src repository
> 
>   Modified files:
>     sbin/hammer          cache.c cmd_show.c 
>   Log:
>   HAMMER utilities:

fix/modification to `stamp' command:
  * bug: don't clobber the time we just calculated
  * bug: actual (year,month) are (tm_year+1900,tm_mon+1), so we need to
	 add first, overwrite, then subtract.

  * feature: if I say `hammer stamp YYYYmmdd', I almost always assume
	it's the same thing as `hammer stamp YYYYmmdd:000000', but that
	may be different from what others think...

Cheers.

diff --git a/sbin/hammer/hammer.c b/sbin/hammer/hammer.c
index d1da775..c2e9b67 100644
--- a/sbin/hammer/hammer.c
+++ b/sbin/hammer/hammer.c
@@ -158,17 +158,20 @@ hammer_parsetime(u_int64_t *tidp, const char *timestr)
 	} else {
 		localtime_r(&t, &tm);
 		seconds = (double)tm.tm_sec;
-		tm.tm_year -= 1900;
-		tm.tm_mon -= 1;
+		tm.tm_year += 1900;
+		tm.tm_mon += 1;
 		n = sscanf(timestr, "%4d%2d%2d:%2d%2d%lf",
 			   &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
 			   &tm.tm_hour, &tm.tm_min, &seconds);
-		tm.tm_mon += 1;
-		tm.tm_year += 1900;
-		tm.tm_sec = (int)seconds;
+		tm.tm_mon -= 1;
+		tm.tm_year -= 1900;
+		/* if [:hhmmss] is omitted, assume :000000.0 */
+		if (n < 4)
+			tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
+		else
+			tm.tm_sec = (int)seconds;
 		t = mktime(&tm);
 	}
-	localtime_r(&t, &tm);
 	*tidp = (u_int64_t)t * 1000000000 + 
 		(seconds - (int)seconds) * 1000000000;
 }

-- 
YONETANI Tomokazu



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]