Changed the set_metadata function to safely check for the date key.