Remove trailing chars from the middle of format too

The old way would just remove trailing characters from the end of the string.
We want to remove from the middle too, so something like:

    ':hh:mm: .%p'

Will become:

    'hh:mm %p'

Also, add a test that would've caught the problem.

Change-Id: I5d5c936fe41c8f4b4b7123c849465f13d9f3a131