summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-10-03 13:26:00 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-10-03 13:26:00 -0700
commit82ecfc252e44ca8ca98c6b6cda507b6386023e1b (patch)
tree425c64352409d3fe2018ae02208b7f98a10b7e07 /lib
parentc9cd187d5aa8fa6607dd463b5f98a65483ae39ce (diff)
downloadpsych-82ecfc252e44ca8ca98c6b6cda507b6386023e1b.zip
1.9.2 compatibility
Diffstat (limited to 'lib')
-rw-r--r--lib/psych/visitors/to_ruby.rb4
-rw-r--r--lib/psych/visitors/yaml_tree.rb26
2 files changed, 25 insertions, 5 deletions
diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb
index fd899f6..b76cd7d 100644
--- a/lib/psych/visitors/to_ruby.rb
+++ b/lib/psych/visitors/to_ruby.rb
@@ -1,5 +1,9 @@
require 'psych/scalar_scanner'
+unless defined?(Regexp::NOENCODING)
+ Regexp::NOENCODING = 32
+end
+
module Psych
module Visitors
###
diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb
index 70db181..1f1acdb 100644
--- a/lib/psych/visitors/yaml_tree.rb
+++ b/lib/psych/visitors/yaml_tree.rb
@@ -311,11 +311,27 @@ module Psych
end
private
- def format_time time
- if time.utc?
- time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
- else
- time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
+ # '%:z' was no defined until 1.9.3
+ if RUBY_VERSION < '1.9.3'
+ def format_time time
+ formatted = time.strftime("%Y-%m-%d %H:%M:%S.%9N")
+
+ if time.utc?
+ formatted += " Z"
+ else
+ zone = time.strftime('%z')
+ formatted += " #{zone[0,3]}:#{zone[3,5]}"
+ end
+
+ formatted
+ end
+ else
+ def format_time time
+ if time.utc?
+ time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
+ else
+ time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
+ end
end
end