MCPcopy Create free account
hub / github.com/AdRoll/baker / setTimes

Method setTimes

filter/timestamp_range.go:56–80  ·  view source on GitHub ↗
(start, end string)

Source from the content-addressed store, hash-verified

54}
55
56func (f *TimestampRange) setTimes(start, end string) error {
57 const timeLayout = "2006-01-02 15:04:05"
58
59 if start == "now" {
60 f.startDate = time.Now().Unix()
61 } else {
62 t, err := time.Parse(timeLayout, start)
63 if err != nil {
64 return fmt.Errorf("start time is invalid: %s", err)
65 }
66 f.startDate = t.Unix()
67 }
68
69 if end == "now" {
70 f.endDate = time.Now().Unix()
71 } else {
72 t, err := time.Parse(timeLayout, end)
73 if err != nil {
74 return fmt.Errorf("end time is invalid: %s", err)
75 }
76 f.endDate = t.Unix()
77 }
78
79 return nil
80}
81
82// Stats implements baker.Filter.
83func (f *TimestampRange) Stats() baker.FilterStats {

Callers 1

NewTimestampRangeFunction · 0.95

Calls 1

ParseMethod · 0.65

Tested by

no test coverage detected