summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/psych/visitors/to_ruby.rb2
-rw-r--r--lib/psych/visitors/yast_builder.rb11
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb
index b4e33ed..40236ce 100644
--- a/lib/psych/visitors/to_ruby.rb
+++ b/lib/psych/visitors/to_ruby.rb
@@ -40,7 +40,7 @@ module Psych
date, time = *(lexeme.split(/[ tT]/, 2))
(yy, m, dd) = date.split('-').map { |x| x.to_i }
- md = time.match /(\d+:\d+:\d+)(\.\d*)?\s*(Z|[-+]\d+(:\d\d)?)?/
+ md = time.match(/(\d+:\d+:\d+)(\.\d*)?\s*(Z|[-+]\d+(:\d\d)?)?/)
(hh, mm, ss) = md[1].split(':').map { |x| x.to_i }
diff --git a/lib/psych/visitors/yast_builder.rb b/lib/psych/visitors/yast_builder.rb
index 9111f8b..1f1eae4 100644
--- a/lib/psych/visitors/yast_builder.rb
+++ b/lib/psych/visitors/yast_builder.rb
@@ -21,6 +21,17 @@ module Psych
raise TypeError, "Can't dump #{target.class}"
end
+ def visit_Time o
+ formatted = o.strftime("%Y-%m-%d %H:%M:%S")
+ if o.utc?
+ formatted += ".%06dZ" % [o.usec]
+ else
+ formatted += ".%06d %d:00" % [o.usec, o.gmt_offset / 3600]
+ end
+
+ append Nodes::Scalar.new formatted
+ end
+
def visit_Date o
append Nodes::Scalar.new o.to_s
end