Sha256: 7fe5a26b21abcad216447781c03811b0a45556d3f6c0a7f213876de8229ce9fc

Contents?: true

Size: 622 Bytes

Versions: 33

Compression:

Stored size: 622 Bytes

Contents

# --- Fix Chronic - can't parse '12th Jan' --- #
begin
  require 'chronic'

  module Chronic

    class << self
      def parse_with_hobo_fix(s)
        if s =~ /^\s*\d+\s*(st|nd|rd|th)\s+[a-zA-Z]+(\s+\d+)?\s*$/ 
          s = s.sub(/\s*\d+(st|nd|rd|th)/) {|s| s[0..-3]}
        end
        
        # Chronic can't parse '1/1/2008 1:00' or '1/1/2008 1:00 PM',
        # so convert them to '1/1/2008 @ 1:00' and '1/1/2008 @ 1:00 PM'
        s = s.sub(/^\s*(\d+\/\d+\/\d+)\s+(\d+:\d+.*)/, '\1 @ \2')
        parse_without_hobo_fix(s)
      end
      alias_method_chain :parse, :hobo_fix
    end
  end
rescue LoadError; end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
hobosupport-1.1.0 lib/hobo_support/fixes/chronic.rb
hobosupport-1.0.3 lib/hobo_support/fixes/chronic.rb
hobosupport-1.1.0.pre4 lib/hobo_support/fixes/chronic.rb
hobosupport-1.1.0.pre3 lib/hobo_support/fixes/chronic.rb
hobo_support-1.3.0.pre19 lib/hobo_support/fixes/chronic.rb
hobo_support-1.3.0.pre18 lib/hobo_support/fixes/chronic.rb
hobosupport-1.1.0.pre2 lib/hobo_support/fixes/chronic.rb
hobosupport-1.1.0.pre0 lib/hobo_support/fixes/chronic.rb
hobosupport-1.0.2 lib/hobo_support/fixes/chronic.rb
hobo_support-1.3.0.pre16 lib/hobo_support/fixes/chronic.rb
hobo_support-1.3.0.pre15 lib/hobo_support/fixes/chronic.rb
hobo_support-1.3.0.pre14 lib/hobo_support/fixes/chronic.rb
hobo_support-1.3.0.pre13 lib/hobo_support/fixes/chronic.rb
hobo_support-1.3.0.pre12 lib/hobo_support/fixes/chronic.rb
hobo_support-1.3.0.pre11 lib/hobo_support/fixes/chronic.rb
hobo_support-1.3.0.pre10 lib/hobo_support/fixes/chronic.rb
hobosupport-1.0.1 lib/hobo_support/fixes/chronic.rb
hobosupport-1.0.0 lib/hobo_support/fixes/chronic.rb
hobosupport-0.9.106 lib/hobo_support/fixes/chronic.rb
hobosupport-0.9.105 lib/hobo_support/fixes/chronic.rb