From df228f906b4f2d4be3e113f042ebe6f579af7e78 Mon Sep 17 00:00:00 2001 From: stan Date: Wed, 30 Oct 2002 11:17:04 +0000 Subject: [PATCH] Now stores DB times as localtime rather than UTC. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@109 e3e1d417-86f3-4887-817a-d78f3d33393f --- src/zm.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/zm.cpp b/src/zm.cpp index e19b30511..04d1df563 100644 --- a/src/zm.cpp +++ b/src/zm.cpp @@ -1302,7 +1302,10 @@ int Camera::camera_count = 0; Event::Event( Monitor *p_monitor, time_t p_start_time ) : monitor( p_monitor ), start_time( p_start_time ) { static char sql[256]; - sprintf( sql, "insert into Events set MonitorId=%d, Name='Event', StartTime=from_unixtime(%d)", monitor->Id(), start_time ); + static char start_time_str[32]; + + strftime( start_time_str, sizeof(start_time_str), "%Y-%m-%d %H:%M:%S", localtime( &start_time ) ); + sprintf( sql, "insert into Events set MonitorId=%d, Name='Event', StartTime='%s'", monitor->Id(), start_time_str ); if ( mysql_query( &dbconn, sql ) ) { Error(( "Can't insert event: %s\n", mysql_error( &dbconn ) )); @@ -1333,7 +1336,10 @@ Event::Event( Monitor *p_monitor, time_t p_start_time ) : monitor( p_monitor ), Event::~Event() { static char sql[256]; - sprintf( sql, "update Events set Name='Event-%d', EndTime = now(), Length = %d, Frames = %d, AlarmFrames = %d, AvgScore = %d, MaxScore = %d where Id = %d", id, (end_time-start_time), frames, alarm_frames, (int)(tot_score/alarm_frames), max_score, id ); + static char end_time_str[32]; + + strftime( end_time_str, sizeof(end_time_str), "%Y-%m-%d %H:%M:%S", localtime( &end_time ) ); + sprintf( sql, "update Events set Name='Event-%d', EndTime = '%s', Length = %d, Frames = %d, AlarmFrames = %d, AvgScore = %d, MaxScore = %d where Id = %d", id, end_time_str, (end_time-start_time), frames, alarm_frames, (int)(tot_score/alarm_frames), max_score, id ); if ( mysql_query( &dbconn, sql ) ) { Error(( "Can't update event: %s\n", mysql_error( &dbconn ) ));