Parsing and validating arbitrary date formats in ruby (on rails)
        Posted  
        
            by Matt Briggs
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Matt Briggs
        
        
        
        Published on 2010-05-31T20:20:11Z
        Indexed on 
            2010/05/31
            20:23 UTC
        
        
        Read the original article
        Hit count: 305
        
I have a requirement to handle custom date formats in an existing app. The idea is that the users have to do with multiple formats from outside sources they have very little control over. We will need to be able to take the format and both validate Dates against it, as well as parse strings specifically in that format. The other thing is that these can be completely arbitrary, like JA == January, FE == February, etc...
to my understanding, chronic only handles parsing (and does it in a more magical way then I can use), and enter code here DateTime#strptime comes close, but doesn't really handle the whole two character month scenario, even with custom formatters. The 'nuclear' option is to write in custom support for edge cases like this, but I would prefer to use a library if something like this exists.
© Stack Overflow or respective owner