Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Parse string dates in specifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
p committed Sep 11, 2011
1 parent 990b908 commit aa13976
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rpg-package-spec.rb
Expand Up @@ -69,6 +69,14 @@
case spec['date']
when Time; spec['date'].utc.strftime('%Y-%m-%d')
when Date; spec['date'].to_s
when String
# Some date formats are not parsed by YAML despite being legitimate;
# e.g. 2011-08-25 00:00:00.000000000Z.
# Use Time.parse to parse such dates.
# Sadly, it looks like Time.parse will silently accept any garbage
# fed to it, meaning truly invalid input is unlikely to be caught.
require 'time'
Time.parse(spec['date']).utc.strftime('%Y-%m-%d')
else fail "unexpected date value: #{spec['date'].inspect}"
end
spec.reject! { |k,v| v.respond_to?(:ivars) }
Expand Down

0 comments on commit aa13976

Please sign in to comment.