Sha256: 7c4b2f0c17de40e9b782b747301a32f4cf71b8fdc2c6abcdbd7a2956ee150e1d

Contents?: true

Size: 633 Bytes

Versions: 30

Compression:

Stored size: 633 Bytes

Contents

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

  module Chronic

    class << self
      def parse_with_hobo_fix(s, *options)
        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, *options)
      end
      alias_method_chain :parse, :hobo_fix
    end
  end
rescue LoadError; end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
hobo_support-2.0.0.pre10 lib/hobo_support/fixes/chronic.rb
hobo_support-2.0.0.pre9 lib/hobo_support/fixes/chronic.rb
hobo_support-2.0.0.pre8 lib/hobo_support/fixes/chronic.rb
hobo_support-1.3.3 lib/hobo_support/fixes/chronic.rb
hobo_support-2.0.0.pre7 lib/hobo_support/fixes/chronic.rb
hobo_support-2.0.0.pre6 lib/hobo_support/fixes/chronic.rb
hobo_support-2.0.0.pre5 lib/hobo_support/fixes/chronic.rb
hobo_support-2.0.0.pre4 lib/hobo_support/fixes/chronic.rb
hobo_support-1.3.2 lib/hobo_support/fixes/chronic.rb
hobo_support-1.3.1 lib/hobo_support/fixes/chronic.rb
hobo_support-2.0.0.pre3 lib/hobo_support/fixes/chronic.rb
hobo_support-2.0.0.pre2 lib/hobo_support/fixes/chronic.rb
hobo_support-2.0.0.pre1 lib/hobo_support/fixes/chronic.rb
hobo_support-1.4.0.pre8 lib/hobo_support/fixes/chronic.rb
hobo_support-1.4.0.pre7 lib/hobo_support/fixes/chronic.rb
hobo_support-1.4.0.pre6 lib/hobo_support/fixes/chronic.rb
hobo_support-1.4.0.pre5 lib/hobo_support/fixes/chronic.rb
hobo_support-1.4.0.pre4 lib/hobo_support/fixes/chronic.rb
hobo_support-1.4.0.pre3 lib/hobo_support/fixes/chronic.rb
hobo_support-1.4.0.pre2 lib/hobo_support/fixes/chronic.rb