From 81645751d54a976a0bd49cf87c0b88bd9623599d Mon Sep 17 00:00:00 2001 From: oetiker Date: Thu, 11 Nov 2010 16:12:17 +0000 Subject: [PATCH] introduce "epoch" as a new base time reference, meaning timestamp 0. This disambiguates between some "at-style" time specs: 11111111 yields an error message: did you really mean month 1111111? and 19711205 denotes Dec 12, 1971 and not the timestamp. The patch allows to write: epoch+11111111s or epoch+19711205s -- Peter Stamfest git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@2147 a5681a0c-68f1-0310-ab6d-d61299d08faa --- doc/rrdfetch.pod | 9 +++++++-- src/rrd.h | 3 ++- src/rrd_parsetime.c | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/doc/rrdfetch.pod b/doc/rrdfetch.pod index 49b8fc2..29f91bc 100644 --- a/doc/rrdfetch.pod +++ b/doc/rrdfetch.pod @@ -165,11 +165,16 @@ single-number date is interpreted as MMDD[YY]YY. I: if you specify the I in this way, the I is REQUIRED as well. -Finally, you can use the words B, B, or B as your time +Finally, you can use the words B, B, B or B as your time reference. B refers to the current moment (and is also the default time reference). B (B) can be used to specify a time relative to the start (end) time for those tools that use these -categories (B, L). +categories (B, L) and B indicates the +*IX epoch (*IX timestamp 0 = 1970-01-01 00:00:00 UTC). B is +useful to disambiguate between a timestamp value and some forms +of abbreviated date/time specifications, because it allows to use +time offset specifications using units, eg. B+19711205s unambiguously +denotes timestamp 19711205 and not 1971-12-05 00:00:00 UTC. Month and day of the week names can be used in their naturally abbreviated form (e.g., Dec for December, Sun for Sunday, etc.). The diff --git a/src/rrd.h b/src/rrd.h index 7e63110..53838c0 100644 --- a/src/rrd.h +++ b/src/rrd.h @@ -284,7 +284,8 @@ extern "C" { typedef enum { ABSOLUTE_TIME, RELATIVE_TO_START_TIME, - RELATIVE_TO_END_TIME + RELATIVE_TO_END_TIME, + RELATIVE_TO_EPOCH } rrd_timetype_t; #define TIME_OK NULL diff --git a/src/rrd_parsetime.c b/src/rrd_parsetime.c index f3a8e2e..1b59f45 100644 --- a/src/rrd_parsetime.c +++ b/src/rrd_parsetime.c @@ -124,7 +124,7 @@ enum { /* symbols */ MIDNIGHT, NOON, TEATIME, - PM, AM, YESTERDAY, TODAY, TOMORROW, NOW, START, END, + PM, AM, YESTERDAY, TODAY, TOMORROW, NOW, START, END, EPOCH, SECONDS, MINUTES, HOURS, DAYS, WEEKS, MONTHS, YEARS, MONTHS_MINUTES, NUMBER, PLUS, MINUS, DOT, COLON, SLASH, ID, JUNK, @@ -157,6 +157,7 @@ static const struct SpecialToken VariousWords[] = { {"s", START}, {"end", END}, {"e", END}, + {"epoch", EPOCH}, {"jan", JAN}, {"feb", FEB}, @@ -859,6 +860,9 @@ char *rrd_parsetime( case MINUS: break; /* jump to OFFSET-SPEC part */ + case EPOCH: + ptv->type = RELATIVE_TO_EPOCH; + goto KeepItRelative; case START: ptv->type = RELATIVE_TO_START_TIME; goto KeepItRelative; -- 2.11.0