Inverting logic of parsing timestamp fields

The current implementation tries to parse every timestamp as a long first
and uses it as a unix timestamp.
This fails if the configured timestamp is like 'YYYYMMDD' and also
resembles a long by coincidence.

This PR tries to fix this issue by trying to parse it as a date first and
only it fails is tried to be parsed as a long from unix timestamp.

Possible problems:
* Performance: Reversing the order might make things slower.
* Wrong parsing: An additional check was added to make sure no negative
  unix timestamps can be generated.

Closes #2937