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-0.9.104 lib/hobo_support/fixes/chronic.rb
hobosupport-0.9.103 lib/hobo_support/fixes/chronic.rb
hobosupport-0.9.102 lib/hobo_support/fixes/chronic.rb
hobosupport-0.9.101 lib/hobo_support/fixes/chronic.rb
hobosupport-0.9.100 lib/hobo_support/fixes/chronic.rb
hobosupport-0.9.0 lib/hobo_support/fixes/chronic.rb
hobosupport-0.8.10 lib/hobo_support/fixes/chronic.rb
hobosupport-0.8.9 lib/hobo_support/fixes/chronic.rb
hobosupport-0.8.8 lib/hobo_support/fixes/chronic.rb
hobosupport-0.8.4 lib/hobo_support/fixes/chronic.rb
hobosupport-0.8.7 lib/hobo_support/fixes/chronic.rb
hobosupport-0.8.6 lib/hobo_support/fixes/chronic.rb
hobosupport-0.8.5 lib/hobo_support/fixes/chronic.rb