Truncate datetime objects to the specifiec level of precision, inspired by PostgreSQL's DATE_TRUNC.