Skip to content

Commit 0da6254

Browse files
committedJan 11, 2018
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 df691d9 commit 0da6254

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
@@ -94,7 +94,7 @@ def parse(text)
9494
# Returns a new String ready for Chronic to parse.
9595
def pre_normalize(text)
9696
text = text.to_s.downcase
97-
text.gsub!(/\b(\d{2})\.(\d{2})\.(\d{4})\b/, '\3 / \2 / \1')
97+
text.gsub!(/\b(\d{1,2})\.(\d{1,2})\.(\d{4})\b/, '\3 / \2 / \1')
9898
text.gsub!(/\b([ap])\.m\.?/, '\1m')
9999
text.gsub!(/(\s+|:\d{2}|:\d{2}\.\d+)\-(\d{2}:?\d{2})\b/, '\1tzminus\2')
100100
text.gsub!(/\./, ':')

0 commit comments

Comments
 (0)
Please sign in to comment.