Browse Source

Improve German date format parser

This allow to parse German dates without leading zeros, e.g. 1.1.2015 instead of 01.01.2015
pull/307/head
Kai Krakow 9 years ago
committed by Kai Krakow
parent
commit
0da6254a11
  1. 2
      lib/chronic/parser.rb

2
lib/chronic/parser.rb

@ -94,7 +94,7 @@ module Chronic
# Returns a new String ready for Chronic to parse.
def pre_normalize(text)
text = text.to_s.downcase
text.gsub!(/\b(\d{2})\.(\d{2})\.(\d{4})\b/, '\3 / \2 / \1')
text.gsub!(/\b(\d{1,2})\.(\d{1,2})\.(\d{4})\b/, '\3 / \2 / \1')
text.gsub!(/\b([ap])\.m\.?/, '\1m')
text.gsub!(/(\s+|:\d{2}|:\d{2}\.\d+)\-(\d{2}:?\d{2})\b/, '\1tzminus\2')
text.gsub!(/\./, ':')

Loading…
Cancel
Save