Factored timestamp parsing into fn

Also fixed 2-space tabs into 4-space tabs
Don't try to apply query parameters if none were given

Previously a query like 'SELECT 1 % 2' would result in an error saying
'incomplete format'. This fixes queries that use percent sign but have
no parameters but there's still additional work to be done, see Issue 11.