// TimestampToTime converts a protobuf Timestamp to a go Time.
774340
func TimestampToTime(timestamp *timestamp.Timestamp) time.Time {
	if timestamp == nil {
		return time.Unix(0, 0).UTC()
	}
	return time.Unix(
		timestamp.Seconds,
		int64(timestamp.Nanos),
	).UTC()
}
331787
func goTime(t C.pn_timestamp_t) time.Time {
	if t == 0 {
		return time.Time{}
	}
	return time.Unix(0, int64(t)*int64(time.Millisecond))
}
605128
func (b *BatchBuilder) Timestamp(t time.Time) *BatchBuilder {
	b.using.Timestamp(t)
	return b
}
1347502
func (namespace *Namespace) TimeKeyPart(key_time goltime.Timestamp) string {
	return fmt.Sprintf("%d:%d:%d:%d:%d:%d:%d",
		key_time.Year, key_time.Month, key_time.Day,
		key_time.Hour, key_time.Min, key_time.Sec, key_time.NanoSec)
}
150565
func ParseDockerTimestamp(s string) (time.Time, error) {
	// Timestamp returned by Docker is in time.RFC3339Nano format.
	return time.Parse(time.RFC3339Nano, s)
}
103013
func (c *ChatDeleteCall) Timestamp(timestamp string) *ChatDeleteCall {
	c.timestamp = timestamp
	return c
}
1316814
func TimeToNTP(t time.Time) uint64 {
	if t.IsZero() {
		return 0
	}
	return uint64(t.Unix()) + ntpDelta
}
1094576
func Timestamp(t time.Time) *timestamp.Timestamp {
	return &timestamp.Timestamp{
		Seconds: t.Unix(),
		Nanos:   int32(t.Nanosecond()),
	}
}
636573
func (c *ChannelsHistoryCall) Timestamp(timestamp string) *ChannelsHistoryCall {
	c.timestamp = timestamp
	return c
}
805655
func TimestampFromHTTPRequest(req *http.Request) Timestamp {
	return CreateTimestamp([]string{
		req.FormValue("year"), req.FormValue("month"), req.FormValue("day"),
		req.FormValue("hour"), req.FormValue("min"), req.FormValue("sec"),
	})
}
326618
func TimestampParse(s string) (Timestamp, error) {
	layout := "2006-01-02T15:04:05.999Z"
	t, e := time.Parse(layout, s)
	if e != nil {
		if strings.HasSuffix(s, "+00:00") || strings.HasSuffix(s, "-00:00") {
			t, e = time.Parse(layout, s[:len(s)-6]+"Z")
		} else if strings.HasSuffix(s, "+0000") || strings.HasSuffix(s, "-0000") {
			t, e = time.Parse(layout, s[:len(s)-5]+"Z")
		}
		if e != nil {
			var ts Timestamp
			return ts, e
		}
	}
	return Timestamp{t}, nil
}
855796
func (m *Time) ProtoTime() *ProtoTime {
	if m == nil {
		return &ProtoTime{}
	}
	return &ProtoTime{
		Timestamp: Timestamp{
			Seconds: m.Time.Unix(),
			Nanos:   int32(m.Time.Nanosecond()),
		},
	}
}
1256525
func ParseTime(timestamp string) (time.Time, error) {
	var err error
	for _, timeFmt := range ValidTimestamps {
		// Try to parse
		t, err := time.Parse(timeFmt, timestamp)
		if err == nil { // If successful, return
			return t, nil
		}
	}
	return time.Now(), err
}
1037982
func Timestamp(ts time.Time) SampleOption {
	return func(s *SSFSample) {
		s.Timestamp = ts.UnixNano()
	}
}
398621
func (p *Process) GetUptime() time.Duration {
	if p.startTime.Nanosecond() == 0 {
		return 0
	}
	return time.Since(p.startTime)
}
608253
func (p *Peer) LastPingTime() time.Time {
	p.statsMtx.RLock()
	lastPingTime := p.lastPingTime
	p.statsMtx.RUnlock()

	return lastPingTime
}
525164
func printTimestamp(v uint32) *bytes.Buffer {
	if v == 0 {
		return bytes.NewBuffer(ZeroTimestamp)
	}

	t := time.Unix(int64(v), 0).UTC()
	year, month, day := t.Date()
	hour, minute, second := t.Clock()

	result := &bytes.Buffer{}
	fmt.Fprintf(result, "%04d-%02d-%02d %02d:%02d:%02d", year, int(month), day, hour, minute, second)
	return result
}