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

Function NewFormatTime

filter/format_time.go:85–107  ·  view source on GitHub ↗
(cfg baker.FilterParams)

Source from the content-addressed store, hash-verified

83}
84
85func NewFormatTime(cfg baker.FilterParams) (baker.Filter, error) {
86 dcfg := cfg.DecodedConfig.(*FormatTimeConfig)
87 dcfg.fillDefaults()
88
89 f := &FormatTime{}
90
91 idx, ok := cfg.FieldByName(dcfg.SrcField)
92 if !ok {
93 return nil, fmt.Errorf("unknown field %q", dcfg.SrcField)
94 }
95 f.src = idx
96
97 idx, ok = cfg.FieldByName(dcfg.DstField)
98 if !ok {
99 return nil, fmt.Errorf("unknown field %q", dcfg.DstField)
100 }
101 f.dst = idx
102
103 f.parse = genParseFun(dcfg.SrcFormat)
104 f.format = genFormatFun(dcfg.DstFormat)
105
106 return f, nil
107}
108
109func (f *FormatTime) Stats() baker.FilterStats {
110 return baker.FilterStats{}

Callers 2

TestFormatTimeFunction · 0.85
TestFormatTimeErrorsFunction · 0.85

Calls 3

genParseFunFunction · 0.85
genFormatFunFunction · 0.85
fillDefaultsMethod · 0.45

Tested by 2

TestFormatTimeFunction · 0.68
TestFormatTimeErrorsFunction · 0.68