-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1572 from ggovi/fix-for-timestamp-coral-frontier
fix for timestamp handling in coral frontier and sqlite plugins
- Loading branch information
Showing
2 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
coral-CORAL_2_3_21-fix-timestamp-format-frontier-sqlite.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
diff --git a/src/FrontierAccess/src/Statement.cpp b/src/FrontierAccess/src/Statement.cpp | ||
index 861bf10..e465e4c 100644 | ||
--- a/src/FrontierAccess/src/Statement.cpp | ||
+++ b/src/FrontierAccess/src/Statement.cpp | ||
@@ -41,66 +41,8 @@ namespace { | ||
if( !timestamp ) | ||
throw coral::Exception( "TimestampParser", "timestamp was zero", "coral::TimestampParser::constructor" ); | ||
|
||
- char t[31]; | ||
- // Copy the original timestamp into our buffer | ||
- strncpy(t, timestamp, 30); | ||
- // Temporary variables | ||
- char* pos01 = t; | ||
- char* pos02 = 0; | ||
- // Parse from 2006-1-12.15.47.0.0 | ||
- | ||
- // Get the year | ||
- pos02 = strchr( pos01, '-' ); | ||
- if( !pos02 ) | ||
- throw coral::Exception( "TimestampParser", "error in parsing the year from timestamp [" + std::string(timestamp) + "]", "coral::TimestampParser::constructor" ); | ||
- | ||
- *pos02 = 0; | ||
- size_t year = atoi(pos01); | ||
- pos01 = pos02 + 1; | ||
- // Get the month | ||
- pos02 = strchr( pos01, '-' ); | ||
- if( !pos02 ) | ||
- throw coral::Exception( "TimestampParser", "error in parsing the month from timestamp [" + std::string(timestamp) + "]", "coral::TimestampParser::constructor" ); | ||
- | ||
- *pos02 = 0; | ||
- size_t month = atoi(pos01); | ||
- pos01 = pos02 + 1; | ||
- // Get the day | ||
- pos02 = strchr( pos01, '.' ); | ||
- if( !pos02 ) | ||
- throw coral::Exception( "TimestampParser", "error in parsing the day from timestamp [" + std::string(timestamp) + "]", "coral::TimestampParser::constructor" ); | ||
- | ||
- *pos02 = 0; | ||
- size_t day = atoi(pos01); | ||
- pos01 = pos02 + 1; | ||
- // Get the hour | ||
- pos02 = strchr( pos01, '.' ); | ||
- if( !pos02 ) | ||
- throw coral::Exception( "TimestampParser", "error in parsing the hour from timestamp [" + std::string(timestamp) + "]", "coral::TimestampParser::constructor" ); | ||
- | ||
- *pos02 = 0; | ||
- size_t hour = atoi(pos01); | ||
- pos01 = pos02 + 1; | ||
- // Get the minute | ||
- pos02 = strchr( pos01, '.' ); | ||
- if( !pos02 ) | ||
- throw coral::Exception( "TimestampParser", "error in parsing the minute from timestamp [" + std::string(timestamp) + "]", "coral::TimestampParser::constructor" ); | ||
- | ||
- *pos02 = 0; | ||
- size_t minute = atoi(pos01); | ||
- pos01 = pos02 + 1; | ||
- // Get the second | ||
- pos02 = strchr( pos01, '.' ); | ||
- if( !pos02 ) | ||
- throw coral::Exception( "TimestampParser", "error in parsing the second from timestamp [" + std::string(timestamp) + "]", "coral::TimestampParser::constructor" ); | ||
- | ||
- *pos02 = 0; | ||
- size_t second = atoi(pos01); | ||
- pos01 = pos02 + 1; | ||
- // Get the msecond | ||
- size_t msecond = atoi(pos01); | ||
- // Create a new coral time | ||
- m_time = new coral::TimeStamp( year, month, day, hour, minute, second, msecond ); | ||
+ // the format supported is: 'YYYY-MM-DD hh:mm:ss' | ||
+ m_time = new coral::TimeStamp( boost::posix_time::time_from_string(std::string(timestamp))); | ||
} | ||
|
||
~TimestampParser() | ||
diff --git a/src/SQLiteAccess/src/SQLiteStatement.cpp b/src/SQLiteAccess/src/SQLiteStatement.cpp | ||
index 6afb78c..71dfdbb 100644 | ||
--- a/src/SQLiteAccess/src/SQLiteStatement.cpp | ||
+++ b/src/SQLiteAccess/src/SQLiteStatement.cpp | ||
@@ -26,7 +26,7 @@ | ||
namespace coral { | ||
namespace SQLiteAccess { | ||
std::string toSimpleString( const boost::posix_time::ptime& time ){ | ||
- boost::posix_time::time_facet* facet = new boost::posix_time::time_facet("%Y-%m-%d %H:%M:%f"); | ||
+ boost::posix_time::time_facet* facet = new boost::posix_time::time_facet("%Y-%m-%d %H:%M:%S%F"); | ||
std::ostringstream os; | ||
os.imbue(std::locale(os.getloc(), facet)); | ||
os << time; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters