messages.go
func (c *MessageService) GetMessagesInRange(start time.Time, end time.Time, data url.Values) MessagePageIterator {
	if start.After(end) {
		panic("start date is after end date")
	}
	d := url.Values{}
	if data != nil {
		for k, v := range data {
			d[k] = v
		}
	}
	d.Del("DateSent")
	d.Del("Page") // just in case
	// Omit these parameters if they are the sentinel values, since I think
	// that API paging will be faster.
	if start != Epoch {
		startFormat := start.UTC().Format(APISearchLayout)
		d.Set("DateSent>", startFormat)
	}
	if end != HeatDeath {
		// If you specify "DateSent<=YYYY-MM-DD", the *latest* result returned
		// will be midnight (the earliest possible second) on DD. We want all of
		// the results for DD so we need to specify DD+1 in the API.
		//
		// TODO validate midnight-instant math more closely, since I don't think
		// Twilio returns the correct results for that instant.
		endFormat := end.UTC().Add(24 * time.Hour).Format(APISearchLayout)
		d.Set("DateSent<", endFormat)
	}
	iter := NewPageIterator(c.client, d, messagesPathPart)
	return &messageDateIterator{
		start: start,
		end:   end,
		p:     iter,
	}
}
func (c *MessageService) GetMessagesInRange(start time.Time, end time.Time, data url.Values) MessagePageIterator {
	if start.After(end) {
		panic("start date is after end date")
	}
	d := url.Values{}
	if data != nil {
		for k, v := range data {
			d[k] = v
		}
	}
	d.Del("DateSent")
	d.Del("Page") // just in case
	// Omit these parameters if they are the sentinel values, since I think
	// that API paging will be faster.
	if start != Epoch {
		startFormat := start.UTC().Format(APISearchLayout)
		d.Set("DateSent>", startFormat)
	}
	if end != HeatDeath {
		// If you specify "DateSent<=YYYY-MM-DD", the *latest* result returned
		// will be midnight (the earliest possible second) on DD. We want all of
		// the results for DD so we need to specify DD+1 in the API.
		//
		// TODO validate midnight-instant math more closely, since I don't think
		// Twilio returns the correct results for that instant.
		endFormat := end.UTC().Add(24 * time.Hour).Format(APISearchLayout)
		d.Set("DateSent<", endFormat)
	}
	iter := NewPageIterator(c.client, d, messagesPathPart)
	return &messageDateIterator{
		start: start,
		end:   end,
		p:     iter,
	}
}
// GetMessagesInRange gets an Iterator containing calls in the range [start,
// end), optionally further filtered by data. GetMessagesInRange panics if
// start is not before end. Any date filters provided in data will be ignored.
// If you have an end, but don't want to specify a start, use twilio.Epoch for
// start. If you have a start, but don't want to specify an end, use
// twilio.HeatDeath for end.
//
// Assumes that Twilio returns resources in chronological order, latest
// first. If this assumption is incorrect, your results will not be correct.
//
// Returned MessagePages will have at most PageSize results, but may have
// fewer, based on filtering.