correctly handle different datetime formats