diff options
author | Reinhard Tartler <siretart@tauware.de> | 2008-01-19 15:08:54 +0100 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2008-01-19 15:08:54 +0100 |
commit | 2733267954e91e394fbb512ea3abb4c497c0752f (patch) | |
tree | d6cdebd8776bceba06a2fb5e4ed06a4744bc1b57 /lib/common/BoxTimeToText.cpp | |
parent | 1d56581c644c53f1b9a182c6574bc2fc5243d4d1 (diff) |
import version 0.11rc1
This commit has been made by 'bzr import'. I used the upstream tarball
of Version 0.11rc1 for creating it. It has the md5sum:
75608d8bb72dff9a556850ccd0ae8cb9
Diffstat (limited to 'lib/common/BoxTimeToText.cpp')
-rw-r--r-- | lib/common/BoxTimeToText.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/lib/common/BoxTimeToText.cpp b/lib/common/BoxTimeToText.cpp index 7997376b..c212297c 100644 --- a/lib/common/BoxTimeToText.cpp +++ b/lib/common/BoxTimeToText.cpp @@ -1,4 +1,4 @@ -// distribution boxbackup-0.10 (svn version: 494) +// distribution boxbackup-0.11rc1 (svn version: 2023_2024) // // Copyright (c) 2003 - 2006 // Ben Summers and contributors. All rights reserved. @@ -58,23 +58,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"); @@ -84,11 +92,17 @@ std::string BoxTimeToISO8601String(box_time_t Time) 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); |