You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2022/01/29 23:37:30 UTC

[skywalking-banyandb] branch main updated: fix timezone issue (#76)

This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git


The following commit(s) were added to refs/heads/main by this push:
     new dc8d405  fix timezone issue (#76)
dc8d405 is described below

commit dc8d4055b774537195d4c8303cc1b9f53916da9c
Author: Jiajing LU <lu...@gmail.com>
AuthorDate: Sun Jan 30 07:37:25 2022 +0800

    fix timezone issue (#76)
---
 banyand/tsdb/segment.go | 4 ++--
 banyand/tsdb/shard.go   | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/banyand/tsdb/segment.go b/banyand/tsdb/segment.go
index 580536c..60897d2 100644
--- a/banyand/tsdb/segment.go
+++ b/banyand/tsdb/segment.go
@@ -192,10 +192,10 @@ func (bc *blockController) startTime(suffix string) (time.Time, error) {
 	switch bc.blockSize.Unit {
 	case HOUR:
 		return time.Date(startTime.Year(), startTime.Month(),
-			startTime.Day(), t.Hour(), 0, 0, 0, time.UTC), nil
+			startTime.Day(), t.Hour(), 0, 0, 0, startTime.Location()), nil
 	case DAY:
 		return time.Date(startTime.Year(), startTime.Month(),
-			t.Day(), t.Hour(), 0, 0, 0, time.UTC), nil
+			t.Day(), t.Hour(), 0, 0, 0, startTime.Location()), nil
 	case MILLISECOND:
 		return time.Parse(millisecondFormat, suffix)
 	}
diff --git a/banyand/tsdb/shard.go b/banyand/tsdb/shard.go
index c65614d..c0e65c7 100644
--- a/banyand/tsdb/shard.go
+++ b/banyand/tsdb/shard.go
@@ -237,11 +237,11 @@ func (sc *segmentController) Format(tm time.Time) string {
 func (sc *segmentController) Parse(value string) (time.Time, error) {
 	switch sc.segmentSize.Unit {
 	case HOUR:
-		return time.Parse(segHourFormat, value)
+		return time.ParseInLocation(segHourFormat, value, time.Local)
 	case DAY:
-		return time.Parse(segDayFormat, value)
+		return time.ParseInLocation(segDayFormat, value, time.Local)
 	case MILLISECOND:
-		return time.Parse(millisecondFormat, value)
+		return time.ParseInLocation(millisecondFormat, value, time.Local)
 	}
 	panic("invalid interval unit")
 }