Skip to content

Commit 3ccdb42

Browse files
committed
Improve German date format parser
This allow to parse German dates without leading zeros, e.g. 1.1.2015 instead of 01.01.2015
1 parent 1b93e33 commit 3ccdb42

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/chronic/parser.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def parse(text)
9393
# Returns a new String ready for Chronic to parse.
9494
def pre_normalize(text)
9595
text = text.to_s.downcase
96-
text.gsub!(/\b(\d{2})\.(\d{2})\.(\d{4})\b/, '\3 / \2 / \1')
96+
text.gsub!(/\b(\d{1,2})\.(\d{1,2})\.(\d{4})\b/, '\3 / \2 / \1')
9797
text.gsub!(/\b([ap])\.m\.?/, '\1m')
9898
text.gsub!(/(\s+|:\d{2}|:\d{2}\.\d{3})\-(\d{2}:?\d{2})\b/, '\1tzminus\2')
9999
text.gsub!(/\./, ':')

0 commit comments

Comments
 (0)