changed pullevents function to include events ending after midnight