Skip to content

Commit

Permalink
Custom time encoding to be range query friendly in YAML encoder.
Browse files Browse the repository at this point in the history
  • Loading branch information
Darrick Wiebe committed Jan 27, 2013
1 parent dfc8511 commit e608385
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/pacer/graph/yaml_encoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def self.encode_property(value)
end
when true, false
value.to_java
when DateTime, Time, Date
value.strftime ' time %Y%m%d%H%M%S%L'
when Array
if value.length == 0
value_type = Fixnum
Expand Down Expand Up @@ -53,7 +55,12 @@ def self.encode_property(value)

def self.decode_property(value)
if value.is_a? String and value[0, 1] == ' '
YAML.load(value[1..-1])
if value[1, 4] == 'time'
# FIXME: we lose the milliseconds here...
Time.parse value[6..-1]
else
YAML.load(value[1..-1])
end
elsif value.is_a? ArrayJavaProxy
value.to_a
else
Expand Down

0 comments on commit e608385

Please sign in to comment.