From: Yukihiro Matsumoto Date: 2005-01-25T15:41:36+09:00 Subject: [ruby-dev:25508] Fw: DateTime questions [newbie] まつもと ゆきひろです [ruby-talk:127729]です。これってバグですか。 --- Date: Sun, 23 Jan 2005 10:03:51 +0900 Posted: Sat, 22 Jan 2005 20:03:46 -0500 From: Navindra Umanee Reply-To: ruby-talk@ruby-lang.org Subject: DateTime questions [newbie] To: ruby-talk@ruby-lang.org (ruby-talk ML) Message-Id: <20050122200346.A14373@cs.mcgill.ca> X-ML-Name: ruby-talk X-Mail-Count: 127729 Hi! I have some newbie questions. > DateTime.strptime('2000-09-28 05:23:01 -0400', '%F %T %z').strftime('%s') => "970132981" > DateTime.strptime('970132981', '%s').strftime('%s') ArgumentError: invalid date from /usr/lib/ruby/1.8/date.rb:485:in `new_with_hash' from /usr/lib/ruby/1.8/date.rb:495:in `strptime' from (irb):31 Why does the first command work but not the second one? 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'? Also, is there a way of printing fractional seconds? I see that DateTime has sec_fraction() but '%N' doesn't seem to work in the string definition. Thanks a lot! Cheers, Navin.