#NEWLINE# def filter_parse_date( stdout , used_locale = None ) : #NEWLINE# #INDENT# ' Construct a datetime object from local date string returned by git show ' #NEWLINE# setlocale ( LC_ALL , ( used_locale or USED_GIT_PARSING_LOCALE ) ) #NEWLINE# match = re . match ( '^(?P<dow>\\w+)\\ {1}(?P<month>\\w+)\\ {1}(?P<day>\\d{1,2})\\ {1}(?P<hour>\\d{1,2})\\:{1}(?P<minute>\\d{1,2})\\:{1}(?P<second>\\d{1,2})\\ {1}(?P<year>\\d+).*$' , stdout , re . UNICODE ) #NEWLINE# if ( not match ) : #NEWLINE# #INDENT# raise ValueError ( ( "Date '%s' is not matching our format, please report bug" % str ( stdout ) ) ) #NEWLINE# #UNINDENT# data = match . groupdict ( ) #NEWLINE# data . update ( dict ( [ ( key , int ( value ) ) for ( key , value ) in data . items ( ) if ( key not in [ 'dow' , 'month' ] ) ] ) ) #NEWLINE# date = datetime . strptime ( ( '%(dow)s %(month)s %(day)02d %(hour)02d:%(minute)02d:%(second)02d %(year)04d' % data ) , '%a %b %d %H:%M:%S %Y' ) #NEWLINE# resetlocale ( ) #NEWLINE# return date