Skip to content

Commit

Permalink
Merge pull request #23 from airween/timeformatfix
Browse files Browse the repository at this point in the history
Added the correct timezone to parsing of dates
  • Loading branch information
fzipi authored Mar 21, 2021
2 parents af56f06 + a4787dc commit 5b20d99
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion waflog/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func (ll *FTWLogLines) getLinesSinceUntil() [][]byte {
ChunkSize: 4096,
}
scanner := backscanner.NewOptions(logfile, int(fi.Size()), backscannerOptions)
tzonename, _ := time.Now().Zone()
tzone := gostradamus.Timezone(tzonename)
for {
line, _, err := scanner.LineBytes()
if err != nil {
Expand All @@ -93,7 +95,7 @@ func (ll *FTWLogLines) getLinesSinceUntil() [][]byte {
date := matchedLine[1]
log.Trace().Msgf("ftw/waflog: matched %s in line %s", date, matchedLine)
// well, go doesn't want to have a proper time format, so we need to use gostradamus
t, err := gostradamus.Parse(string(date), ll.TimeFormat)
t, err := gostradamus.ParseInTimezone(string(date), ll.TimeFormat, tzone)
if err != nil {
log.Error().Msgf("ftw/waflog: error parsing date %s", err.Error())
// return with what we got up to now
Expand Down

0 comments on commit 5b20d99

Please sign in to comment.