mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-24 08:38:45 +05:00
Updated the layout for time in CDR
This commit is contained in:
committed by
Dan Christian Bogos
parent
ea930cd31c
commit
e280045af9
@@ -323,14 +323,8 @@ func (cdr *CDR) exportFieldValue(cfgCdrFld *config.FCTemplate, filterS *FilterS)
|
||||
}
|
||||
cdrVal = cdr.FormatCost(cfgCdrFld.CostShiftDigits, roundDec)
|
||||
case utils.MetaExp + utils.NestingSep + utils.SetupTime:
|
||||
if cfgCdrFld.Layout == "" {
|
||||
cfgCdrFld.Layout = time.RFC3339
|
||||
}
|
||||
cdrVal = cdr.SetupTime.Format(cfgCdrFld.Layout)
|
||||
case utils.MetaExp + utils.NestingSep + utils.AnswerTime: // Format time based on layout
|
||||
if cfgCdrFld.Layout == "" {
|
||||
cfgCdrFld.Layout = time.RFC3339
|
||||
}
|
||||
cdrVal = cdr.AnswerTime.Format(cfgCdrFld.Layout)
|
||||
case utils.MetaExp + utils.NestingSep + utils.Destination:
|
||||
cdrVal, err = cdr.FieldAsString(rsrFld)
|
||||
@@ -369,9 +363,6 @@ func (cdr *CDR) formatField(cfgFld *config.FCTemplate, httpSkipTLSCheck bool,
|
||||
if err != nil { // Only one rule makes sense here
|
||||
return "", err
|
||||
}
|
||||
if cfgFld.Layout == "" {
|
||||
cfgFld.Layout = time.RFC3339
|
||||
}
|
||||
outVal = dtFld.Format(cfgFld.Layout)
|
||||
case utils.MetaHTTPPost:
|
||||
var outValByte []byte
|
||||
|
||||
@@ -1139,13 +1139,13 @@ func TestCDRexportFieldValue(t *testing.T) {
|
||||
}
|
||||
|
||||
cfgCdrFld := &config.FCTemplate{Path: "*exp.SetupTime", Type: utils.META_COMPOSED,
|
||||
Value: config.NewRSRParsersMustCompile("~SetupTime", true, utils.INFIELD_SEP)}
|
||||
Value: config.NewRSRParsersMustCompile("~SetupTime", true, utils.INFIELD_SEP),Layout: time.RFC3339}
|
||||
|
||||
eVal := "2013-11-07T08:42:20Z"
|
||||
if val, err := cdr.exportFieldValue(cfgCdrFld, nil); err != nil {
|
||||
t.Error(err)
|
||||
} else if val != eVal {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eVal, val)
|
||||
t.Errorf("Expecting: %+v, received: %+v", eVal, utils.ToJSON(val))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user