Doc improvements (#6)

* add default datetime format, fix default format usage
* fixed format tests
* make reference time configurable
* improve doc
This commit is contained in:
T.v.Dein
2025-09-25 22:13:40 +02:00
committed by GitHub
parent ef4cc8b84b
commit d138af85f3
7 changed files with 162 additions and 40 deletions

View File

@@ -45,9 +45,10 @@ func NewTP(conf *Config, ref ...time.Time) *TimestampProccessor {
modnow.TimeFormats = append(modnow.TimeFormats, formats...)
tp := &TimestampProccessor{Config: *conf, Reference: time.Now()}
tp := &TimestampProccessor{Config: *conf, Reference: conf.refTime}
if len(ref) == 1 {
// overwritten externally by unit test
tp.Reference = ref[0]
}
@@ -73,9 +74,9 @@ func (tp *TimestampProccessor) Parse(timestamp string) (time.Time, error) {
return ts, err
}
if tp.TZ != "" {
if tp.tz != "" {
// apply custom timezone
zone, _ := time.LoadLocation(tp.TZ)
zone, _ := time.LoadLocation(tp.tz)
ts = ts.In(zone)
}
@@ -105,7 +106,8 @@ func (tp *TimestampProccessor) SingleTimestamp(timestamp string) error {
return err
}
tp.Print(ts)
tp.Print(TPdatetime{TimestampProccessor: *tp, Data: ts})
//tp.Print(ts)
return nil
}