[Box Backup-commit] COMMIT r1036 - in box/chris/merge: bin/bbackupquery lib/common

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Sat Oct 14 16:08:45 BST 2006


Author: chris
Date: 2006-10-14 16:08:45 +0100 (Sat, 14 Oct 2006)
New Revision: 1036

Modified:
   box/chris/merge/bin/bbackupquery/BackupQueries.cpp
   box/chris/merge/lib/common/BoxTimeToText.cpp
   box/chris/merge/lib/common/BoxTimeToText.h
Log:
 * Add option to bbackupquery list command to show times in UTC or local time
   (refs #3)


Modified: box/chris/merge/bin/bbackupquery/BackupQueries.cpp
===================================================================
--- box/chris/merge/bin/bbackupquery/BackupQueries.cpp	2006-10-14 14:59:55 UTC (rev 1035)
+++ box/chris/merge/bin/bbackupquery/BackupQueries.cpp	2006-10-14 15:08:45 UTC (rev 1036)
@@ -180,7 +180,7 @@
 	{
 		{ "quit", "" },
 		{ "exit", "" },
-		{ "list", "rodIFtsh", },
+		{ "list", "rodIFtTsh", },
 		{ "pwd",  "" },
 		{ "cd",   "od" },
 		{ "lcd",  "" },
@@ -350,8 +350,9 @@
 	#define LIST_OPTION_ALLOWOLD		'o'
 	#define LIST_OPTION_ALLOWDELETED	'd'
 	#define LIST_OPTION_NOOBJECTID		'I'
-	#define LIST_OPTION_NOFLAGS			'F'
-	#define LIST_OPTION_TIMES			't'
+	#define LIST_OPTION_NOFLAGS		'F'
+	#define LIST_OPTION_TIMES_LOCAL		't'
+	#define LIST_OPTION_TIMES_UTC		'T'
 	#define LIST_OPTION_SIZEINBLOCKS	's'
 	#define LIST_OPTION_DISPLAY_HASH	'h'
 
@@ -468,13 +469,21 @@
 			}
 		}
 		
-		if(opts[LIST_OPTION_TIMES])
+		if(opts[LIST_OPTION_TIMES_UTC])
 		{
-			// Show times...
+			// Show UTC times...
 			std::string time = BoxTimeToISO8601String(
-				en->GetModificationTime());
+				en->GetModificationTime(), false);
 			printf("%s ", time.c_str());
 		}
+
+		if(opts[LIST_OPTION_TIMES_LOCAL])
+		{
+			// Show local times...
+			std::string time = BoxTimeToISO8601String(
+				en->GetModificationTime(), true);
+			printf("%s ", time.c_str());
+		}
 		
 		if(opts[LIST_OPTION_DISPLAY_HASH])
 		{

Modified: box/chris/merge/lib/common/BoxTimeToText.cpp
===================================================================
--- box/chris/merge/lib/common/BoxTimeToText.cpp	2006-10-14 14:59:55 UTC (rev 1035)
+++ box/chris/merge/lib/common/BoxTimeToText.cpp	2006-10-14 15:08:45 UTC (rev 1036)
@@ -20,23 +20,31 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BoxTimeToISO8601String(box_time_t)
-//		Purpose: Convert a 64 bit box time to a ISO 8601 complient string
+//		Name:    BoxTimeToISO8601String(box_time_t, bool)
+//		Purpose: Convert a 64 bit box time to a ISO 8601 compliant 
+//			string, either in local or UTC time
 //		Created: 2003/10/10
 //
 // --------------------------------------------------------------------------
-std::string BoxTimeToISO8601String(box_time_t Time)
+std::string BoxTimeToISO8601String(box_time_t Time, bool localTime)
 {
+	time_t timeInSecs = BoxTimeToSeconds(Time);
+	char str[128];	// more than enough space
+
 #ifdef WIN32
 	struct tm *time;
-	time_t bob = BoxTimeToSeconds(Time);
+	__time64_t winTime = timeInSecs;
 
-	__time64_t winTime = bob;
+	if(localTime)
+	{
+		time = _localtime64(&winTime);
+	}
+	else
+	{
+		time = _gmtime64(&winTime);
+	}
 
-	time = _gmtime64(&winTime);
-	char str[128];	// more than enough space
-	
-	if ( time == NULL )
+	if(time == NULL)
 	{
 		// ::sprintf(str, "%016I64x ", bob);
 		return std::string("unable to convert time");
@@ -46,11 +54,17 @@
 		time->tm_mon + 1, time->tm_mday, time->tm_hour, 
 		time->tm_min, time->tm_sec);
 #else // ! WIN32
-	time_t timeInSecs = BoxTimeToSeconds(Time);
 	struct tm time;
-	gmtime_r(&timeInSecs, &time);
+
+	if(localTime)
+	{
+		localtime_r(&timeInSecs, &time);
+	}
+	else
+	{
+		gmtime_r(&timeInSecs, &time);
+	}
 	
-	char str[128];	// more than enough space
 	sprintf(str, "%04d-%02d-%02dT%02d:%02d:%02d", time.tm_year + 1900,
 		time.tm_mon + 1, time.tm_mday, time.tm_hour, 
 		time.tm_min, time.tm_sec);

Modified: box/chris/merge/lib/common/BoxTimeToText.h
===================================================================
--- box/chris/merge/lib/common/BoxTimeToText.h	2006-10-14 14:59:55 UTC (rev 1035)
+++ box/chris/merge/lib/common/BoxTimeToText.h	2006-10-14 15:08:45 UTC (rev 1036)
@@ -13,7 +13,7 @@
 #include <string>
 #include "BoxTime.h"
 
-std::string BoxTimeToISO8601String(box_time_t Time);
+std::string BoxTimeToISO8601String(box_time_t Time, bool localTime);
 
 #endif // BOXTIMETOTEXT__H
 




More information about the Boxbackup-commit mailing list