Created
September 30, 2008 19:36
-
-
Save chapados/13926 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
requrie 'yaml' | |
class DateTime | |
yaml_as "tag:ruby.yaml.org,2002:datetime" | |
def DateTime.yaml_new(klass, tag, val) | |
if String === val | |
self.parse(val) | |
else | |
raise YAML::TypeError, "Invalid DateTime: " + val.inspect | |
end | |
end | |
def to_yaml( opts = {} ) | |
YAML::quick_emit( object_id, opts ) do |out| | |
out.scalar( taguri, self.to_s, :plain ) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment