From: Tobias Oetiker Date: Mon, 1 Jun 2009 13:58:58 +0000 (+0000) Subject: make negative update times work as diescribed in the documentation (-5 is NOW-5seconds) X-Git-Tag: 1.3.9~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c903b2a479d2f0bb0551662c9a30cb3d71ae1f8f;p=thirdparty%2Frrdtool-1.x.git make negative update times work as diescribed in the documentation (-5 is NOW-5seconds) this takes care of debian bug 332766 git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.3/program@1836 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/src/rrd_update.c b/src/rrd_update.c index 3ee6ce5e..79583507 100644 --- a/src/rrd_update.c +++ b/src/rrd_update.c @@ -951,6 +951,11 @@ static int get_time_from_reading( return -1; }; setlocale(LC_NUMERIC, old_locale); + if (tmp < 0.0){ + gettimeofday(&tmp_time, 0); + tmp = (double)tmp_time.tv_sec + (double)tmp_time.tv_usec * 1e-6f + tmp; + } + *current_time = floor(tmp); *current_time_usec = (long) ((tmp - (double) *current_time) * 1e6f); }