Commit a2ba74c154a4a05ddb005dfd0c6bfe0fa3a6d89c
Committed by
Carlos Morais
1 parent
77c1e68b
Exists in
master
and in
28 other branches
[mezuro] Fix date with milliseconds problem
Showing
2 changed files
with
7 additions
and
8 deletions
Show diff stats
plugins/mezuro/lib/kalibro/client/module_result_client.rb
| ... | ... | @@ -13,7 +13,7 @@ class Kalibro::Client::ModuleResultClient |
| 13 | 13 | def module_result(project_name, module_name, date) |
| 14 | 14 | hash = @port.request(:get_module_result, |
| 15 | 15 | {:project_name => project_name, :module_name => module_name, |
| 16 | - :date => date_with_milliseconds(date)})[:module_result] | |
| 16 | + :date => Kalibro::Entitites::Entity.date_with_milliseconds(date)})[:module_result] | |
| 17 | 17 | Kalibro::Entities::ModuleResult.from_hash(hash) |
| 18 | 18 | end |
| 19 | 19 | |
| ... | ... | @@ -23,11 +23,4 @@ class Kalibro::Client::ModuleResultClient |
| 23 | 23 | Kalibro::Entities::Entity.new.to_entity_array(value, Kalibro::Entities::ModuleResult) |
| 24 | 24 | end |
| 25 | 25 | |
| 26 | - private | |
| 27 | - | |
| 28 | - def date_with_milliseconds(date) | |
| 29 | - milliseconds = "." + (date.sec_fraction * 60 * 60 * 24 * 1000).to_s | |
| 30 | - date.to_s[0..18] + milliseconds + date.to_s[19..-1] | |
| 31 | - end | |
| 32 | - | |
| 33 | 26 | end |
| 34 | 27 | \ No newline at end of file | ... | ... |
plugins/mezuro/lib/kalibro/entities/entity.rb
| ... | ... | @@ -6,6 +6,11 @@ class Kalibro::Entities::Entity |
| 6 | 6 | entity |
| 7 | 7 | end |
| 8 | 8 | |
| 9 | + def self.date_with_milliseconds(date) | |
| 10 | + milliseconds = "." + (date.sec_fraction * 60 * 60 * 24 * 1000).to_s | |
| 11 | + date.to_s[0..18] + milliseconds + date.to_s[19..-1] | |
| 12 | + end | |
| 13 | + | |
| 9 | 14 | def set(field, value) |
| 10 | 15 | send("#{field}=", value) if not field.to_s.start_with? '@' |
| 11 | 16 | end |
| ... | ... | @@ -55,6 +60,7 @@ class Kalibro::Entities::Entity |
| 55 | 60 | def convert_to_hash(value) |
| 56 | 61 | return value.collect { |element| convert_to_hash(element) } if value.is_a?(Array) |
| 57 | 62 | return value.to_hash if value.is_a?(Kalibro::Entities::Entity) |
| 63 | + return date_with_milliseconds(value) if value.is_a?(DateTime) | |
| 58 | 64 | return 'INF' if value.is_a?(Float) and value.infinite? == 1 |
| 59 | 65 | return '-INF' if value.is_a?(Float) and value.infinite? == -1 |
| 60 | 66 | value | ... | ... |