refactoring of the create_format_pattern

The current code is hard to read so I refactored it. Would be nice if you'd take it.

BTW:  I have a logging extension at https://github.com/preisanalytics/logging-odd_even that summerizes all my small patches into a usefull extension (I hope).

THX