Yukihiro Matsumoto <matz / ruby-lang.org> wrote:
> |Out of curiosity is there a standard/builtin way of printing ISO8601
> |date format instead of having to use to_yaml and chopping off the "---
> |" garbage string at the beginning of the input or having to manually
> |specify '%F %T %z'?  
> 
> How about DateTime#to_s?

After driving myself mad, I finally realised that in fact this does
not work and DateTime#to_yaml seems to be broken as well.  

irb(main):029:0> YAML::load(DateTime.now.to_yaml).class
=> String  # Should not be String!  Either DateTime or Time.

irb(main):030:0> DateTime.now.to_yaml
=> "--- 2005-01-27T22:40:56-0500"

The problem is that the above is not iso8601 because the timezone is
-0500 instead of -05:00.  Hard to catch when you're not looking too
close like me... :-)

The good news is that I finally realised I could eliminate DateTime
altogether and do everything with Time.  A big simplification!  At
least until 2038.

irb(main):031:0> YAML::load(Time.now.to_yaml).class
=> Time

Woohoo!

Cheers,
Navin.