Mercurial > gemma
changeset 4074:eb2f949ddfa2
Rename TimeGuesser to TimeParser.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 25 Jul 2019 15:08:11 +0200 |
parents | 5867dcf8e93c |
children | cb74aa69954e |
files | pkg/imports/agm.go pkg/imports/fd.go pkg/imports/wp.go pkg/misc/time.go pkg/soap/nts/service.go |
diffstat | 5 files changed, 11 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/imports/agm.go Thu Jul 25 13:31:51 2019 +0200 +++ b/pkg/imports/agm.go Thu Jul 25 15:08:11 2019 +0200 @@ -103,10 +103,10 @@ return os.RemoveAll(agm.Dir) } -var guessDate = misc.TimeGuesser([]string{ +var guessDate = misc.TimeParser([]string{ "02.01.2006 15:04", "2006-01-02T15:04:05-07:00", -}).Guess +}).Parse type timetz struct{ time.Time }
--- a/pkg/imports/fd.go Thu Jul 25 13:31:51 2019 +0200 +++ b/pkg/imports/fd.go Thu Jul 25 15:08:11 2019 +0200 @@ -48,11 +48,11 @@ type fdTime struct{ time.Time } -var guessFDTime = misc.TimeGuesser([]string{ +var guessFDTime = misc.TimeParser([]string{ "20060102", "2006", "", -}).Guess +}).Parse func (fdt *fdTime) UnmarshalJSON(data []byte) error { var s string
--- a/pkg/imports/wp.go Thu Jul 25 13:31:51 2019 +0200 +++ b/pkg/imports/wp.go Thu Jul 25 15:08:11 2019 +0200 @@ -418,7 +418,7 @@ feedback.Info( "Matching points to lines with a precision of %.4fm.", precision) - parseDate := misc.TimeGuesser([]string{"02.01.2006"}).Guess + parseDate := misc.TimeParser([]string{"02.01.2006"}).Parse insertStmt, err := tx.PrepareContext(ctx, insertWaterwayProfileSQL) if err != nil {
--- a/pkg/misc/time.go Thu Jul 25 13:31:51 2019 +0200 +++ b/pkg/misc/time.go Thu Jul 25 15:08:11 2019 +0200 @@ -15,14 +15,14 @@ import "time" -// TimeGuesser is a list of time formats. -type TimeGuesser []string +// TimeParser is a list of time formats. +type TimeParser []string -// Guess tries to parse a given string by the entries of the layout +// Parse tries to parse a given string by the entries of the layout // list one after another. The first matching time is returned. // If no layout matches the last error is returned or time zero // if the layout list is empty. -func (tg TimeGuesser) Guess(s string) (time.Time, error) { +func (tg TimeParser) Parse(s string) (time.Time, error) { var err error var t time.Time for _, layout := range tg {
--- a/pkg/soap/nts/service.go Thu Jul 25 13:31:51 2019 +0200 +++ b/pkg/soap/nts/service.go Thu Jul 25 15:08:11 2019 +0200 @@ -22,10 +22,10 @@ "gemma.intevation.de/gemma/pkg/soap" ) -var guessDateTime = misc.TimeGuesser([]string{ +var guessDateTime = misc.TimeParser([]string{ "2006-01-02T15:04:05", "2006-01-02T15:04:05-07:00", -}).Guess +}).Parse type DateTime struct{ time.Time }