Skip to content

Commit

Permalink
Make sure dates are in UTC before sending them to PuppetDB
Browse files Browse the repository at this point in the history
It seems like newer versions of PuppetDB only accept dates in UTC and
only with "Z" as time zone specifier, not "+00:00". So change to use
that instead.

Fixes #81
  • Loading branch information
dalen committed Dec 14, 2015
1 parent c09b39d commit d363a16
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/puppetdb/astnode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def evaluate(mode = [:nodes])
value
when :date
require 'chronic'
ret = Chronic.parse(value, :guess => false).first.iso8601
ret = Chronic.parse(value, :guess => false).first.utc.iso8601
fail "Failed to parse datetime: #{value}" if ret.nil?
ret
when :booleanop
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/puppetdb/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
end

it 'should parse dates in queries' do
date = Time.new(2014, 9, 9).iso8601
date = Time.new(2014, 9, 9).utc.strftime('%FT%TZ')
parser.parse('#node.report_timestamp<@"Sep 9, 2014"').should eq ['in', 'certname', ['extract', 'certname', ['select_nodes', ['<', 'report_timestamp', date]]]]
end

Expand Down

0 comments on commit d363a16

Please sign in to comment.