// ByExpiryDate sorts the Pages by publish date and returns a copy.
//
// Adjacent invocations on the same receiver will return a cached result.
//
// This may safely be executed  in parallel.
170974
func (p Pages) ByExpiryDate() Pages {

	const key = "pageSort.ByExpiryDate"

	expDate := func(p1, p2 Page) bool {
		return p1.ExpiryDate().Unix() < p2.ExpiryDate().Unix()
	}

	pages, _ := spc.get(key, pageBy(expDate).Sort, p)

	return pages
}
710834
func (s *GetBackupPlanOutput) SetLastExecutionDate(v time.Time) *GetBackupPlanOutput {
	s.LastExecutionDate = &v
	return s
}
1288253
func GetDateBytes(buf []byte, year int, month int, day int) []byte {
	q := year / 100
	p := q << 1
	buf[0] = digit2[p]
	buf[1] = digit2[p+1]
	p = (year - q*100) << 1
	buf[2] = digit2[p]
	buf[3] = digit2[p+1]
	p = month << 1
	buf[4] = digit2[p]
	buf[5] = digit2[p+1]
	p = day << 1
	buf[6] = digit2[p]
	buf[7] = digit2[p+1]
	return buf[:8]
}
867587
func DateFromTime(t time.Time) Date {
	year, month, day := t.Date()
	return DateFor(year, month, day)
}
353134
func lexDateAfterYear(lx *lexer) stateFn {
	formats := []rune{
		// digits are '0'.
		// everything else is direct equality.
		'0', '0', '-', '0', '0',
		'T',
		'0', '0', ':', '0', '0', ':', '0', '0',
		'Z',
	}
	for _, f := range formats {
		r := lx.next()
		if f == '0' {
			if !unicode.IsDigit(r) {
				return lx.errorf("Expected digit in ISO8601 datetime, "+
					"but found '%v' instead.", r)
			}
		} else if f != r {
			return lx.errorf("Expected '%v' in ISO8601 datetime, "+
				"but found '%v' instead.", f, r)
		}
	}
	lx.emit(itemDatetime)
	return lx.pop()
}
1020617
func (date Date) Before(other Date) bool {
	return date.Time.Before(other.Time)
}
704419
func (s *BackupSummary) SetBackupExpiryDateTime(v time.Time) *BackupSummary {
	s.BackupExpiryDateTime = &v
	return s
}
992145
func (ui *UI) UserFriendlyDate(input time.Time) string {
	return input.Local().Format("Mon 02 Jan 15:04:05 MST 2006")
}
766633
func (c *Cache) runExpiryLoop() {
	var expiryTimer *time.Timer
	for {
		// If we have a previous timer, stop it.
		if expiryTimer != nil {
			expiryTimer.Stop()
		}

		// Get the entry expiring soonest
		var entry *cacheEntryExpiry
		var expiryCh <-chan time.Time
		c.entriesLock.RLock()
		if len(c.entriesExpiryHeap.Entries) > 0 {
			entry = c.entriesExpiryHeap.Entries[0]
			expiryTimer = time.NewTimer(entry.Expires.Sub(time.Now()))
			expiryCh = expiryTimer.C
		}
		c.entriesLock.RUnlock()

		select {
		case <-c.stopCh:
			return
		case <-c.entriesExpiryHeap.NotifyCh:
			// Entries changed, so the heap may have changed. Restart loop.

		case <-expiryCh:
			c.entriesLock.Lock()

			// Entry expired! Remove it.
			delete(c.entries, entry.Key)
			heap.Remove(c.entriesExpiryHeap, entry.HeapIndex)

			// This is subtle but important: if we race and simultaneously
			// evict and fetch a new value, then we set this to -1 to
			// have it treated as a new value so that the TTL is extended.
			entry.HeapIndex = -1

			// Set some metrics
			metrics.IncrCounter([]string{"consul", "cache", "evict_expired"}, 1)
			metrics.SetGauge([]string{"consul", "cache", "entries_count"}, float32(len(c.entries)))

			c.entriesLock.Unlock()
		}
	}
}
708369
func (r Virtual_Guest) GetBandwidthDataByDate(startDateTime *datatypes.Time, endDateTime *datatypes.Time, networkType *string) (resp []datatypes.Metric_Tracking_Object_Data, err error) {
	params := []interface{}{
		startDateTime,
		endDateTime,
		networkType,
	}
	err = r.Session.DoRequest("SoftLayer_Virtual_Guest", "getBandwidthDataByDate", params, &r.Options, &resp)
	return
}
1231897
func (r Virtual_Guest) GetMemoryMetricDataByDate(startDateTime *datatypes.Time, endDateTime *datatypes.Time) (resp []datatypes.Metric_Tracking_Object_Data, err error) {
	params := []interface{}{
		startDateTime,
		endDateTime,
	}
	err = r.Session.DoRequest("SoftLayer_Virtual_Guest", "getMemoryMetricDataByDate", params, &r.Options, &resp)
	return
}
293012
func (m *MarketplacePurchaseEvent) GetEffectiveDate() Timestamp {
	if m == nil || m.EffectiveDate == nil {
		return Timestamp{}
	}
	return *m.EffectiveDate
}
973189
func (s *Activation) SetExpirationDate(v time.Time) *Activation {
	s.ExpirationDate = &v
	return s
}
1027425
func (p *Pagination) HasNextPage() bool {
	if !p.started {
		return true
	}

	hasNextPage := len(p.nextTokens) != 0
	if p.EndPageOnSameToken {
		return hasNextPage && !awsutil.DeepEqual(p.nextTokens, p.prevTokens)
	}
	return hasNextPage
}
452579
func (s *AssociationDescription) SetLastExecutionDate(v time.Time) *AssociationDescription {
	s.LastExecutionDate = &v
	return s
}
1081886
func (s *AssociationExecution) SetLastExecutionDate(v time.Time) *AssociationExecution {
	s.LastExecutionDate = &v
	return s
}
1337503
func (p Pages) ByDate() Pages {

	const key = "pageSort.ByDate"

	date := func(p1, p2 Page) bool {
		return p1.Date().Unix() < p2.Date().Unix()
	}

	pages, _ := spc.get(key, pageBy(date).Sort, p)

	return pages
}