MCPcopy Create free account
hub / github.com/brimdata/super / lookupDatePartEval

Function lookupDatePartEval

runtime/sam/expr/function/datepart.go:30–71  ·  view source on GitHub ↗
(part string)

Source from the content-addressed store, hash-verified

28}
29
30func lookupDatePartEval(part string) func(nano.Ts) int64 {
31 switch part {
32 case "day":
33 return func(ts nano.Ts) int64 {
34 return int64(ts.Time().Day())
35 }
36 case "dow", "dayofweek":
37 return func(ts nano.Ts) int64 {
38 return int64(ts.Time().Weekday())
39 }
40 case "hour":
41 return func(ts nano.Ts) int64 {
42 return int64(ts.Time().Hour())
43 }
44 case "microseconds":
45 return func(ts nano.Ts) int64 {
46 return int64(ts.Time().Second()*1e6 + ts.Time().Nanosecond()/1e3)
47 }
48 case "milliseconds":
49 return func(ts nano.Ts) int64 {
50 return int64(ts.Time().Second()*1e3 + ts.Time().Nanosecond()/1e6)
51 }
52 case "minute":
53 return func(ts nano.Ts) int64 {
54 return int64(ts.Time().Minute())
55 }
56 case "month":
57 return func(ts nano.Ts) int64 {
58 return int64(ts.Time().Month())
59 }
60 case "second":
61 return func(ts nano.Ts) int64 {
62 return int64(ts.Time().Second())
63 }
64 case "year":
65 return func(ts nano.Ts) int64 {
66 return int64(ts.Time().Year())
67 }
68 default:
69 return nil
70 }
71}

Callers 1

CallMethod · 0.85

Calls 1

TimeMethod · 0.45

Tested by

no test coverage detected