diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d470144ac..d881d47613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Bugfixes +- [Issue #500](https://github.com/influxdb/influxdb/issues/500). Support `y` sufix in time durations - [Issue #501](https://github.com/influxdb/influxdb/issues/501). Writes with invalid payload should be rejected ## v0.6.0 [2014-05-02] diff --git a/src/common/helpers.go b/src/common/helpers.go index e11c469ecb..b78a79c216 100644 --- a/src/common/helpers.go +++ b/src/common/helpers.go @@ -37,6 +37,8 @@ func ParseTimeDuration(value string) (int64, error) { return int64(parsedFloat * 24 * float64(time.Hour)), nil case 'w': return int64(parsedFloat * 7 * 24 * float64(time.Hour)), nil + case 'y': + return int64(parsedFloat * 365 * 24 * float64(time.Hour)), nil } lastChar := value[len(value)-1] diff --git a/src/parser/parser_test.go b/src/parser/parser_test.go index e8a8a21e90..a366d637d7 100644 --- a/src/parser/parser_test.go +++ b/src/parser/parser_test.go @@ -2,9 +2,9 @@ package parser import ( "fmt" - . "launchpad.net/gocheck" "testing" "time" + . "launchpad.net/gocheck" ) // Hook up gocheck into the gotest runner. @@ -419,6 +419,7 @@ func (self *QueryParserSuite) TestTimeWithNegativeEndTime(c *C) { func (self *QueryParserSuite) TestParseSelectWithTimeCondition(c *C) { queries := map[string]time.Time{ "select value, time from t where time > now() - 1d and time < now() - 1m;": time.Now().Add(-time.Minute).Round(time.Minute).UTC(), + "select value, time from t where time > now() - 1d and time < now() - 1y;": time.Now().Add(-365 * 24 * time.Hour).Round(time.Minute).UTC(), "select value, time from t where time > now() - 1d and time < now();": time.Now().Round(time.Minute).UTC(), } for query, expected := range queries {