Refactor the code for converting 'Date' string to 'DateTime'

Change-Id: I20632258709856cd4c6680e1c8a1d92271ad0453
Reviewed-on: https://gerrit.libreoffice.org/7817
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>