Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Psych treats CAS registry numbers as dates #58

erebor opened this Issue · 1 comment

1 participant


When trying to yaml-ize Chemical Abstract Service numbers (, the format of the string leads psych to think it's a date.

For instance, the CAS registry number of water is '7732-18-5'. So we get this:

1.9.3p0 :043 > {:cas => '7732-18-5'}.to_yaml
ArgumentError: invalid date
from /Users/rew/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/psych/scalar_scanner.rb:45:in strptime'
from /Users/rew/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/psych/scalar_scanner.rb:45:in

The regexp being triggered is thusly:

  when /^\d{4}-\d{1,2}-\d{1,2}$/

There my be a way to alter psych's behavior other than hacking up a copy of the gem, but I don't know what it might be. Unfortunately, I don't have the option to convince the CAS people to not use 4-digit-prefix CAS numbers. :)


Mea culpa, didn't check the closed issues to see that this is duplicate of #47 and #42 .

@erebor erebor closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.