Skip to content

Commit

Permalink
Merge pull request #704 from isucon/extra/fix-initialdata-timezone
Browse files Browse the repository at this point in the history
[initial data]initial-data生成時のtimezoneを固定
  • Loading branch information
buchy authored Aug 1, 2021
2 parents d92e6cb + 809c56f commit 7adf61b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 2 additions & 0 deletions extra/initial-data/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const (
)

func init() {
loc, _ := time.LoadLocation("Asia/Tokyo")
time.Local = loc
t, _ := time.Parse(time.RFC3339, "2021-07-01T00:00:00+07:00")
rand.Seed(t.UnixNano())
uuid.SetRand(rand.New(rand.NewSource(t.UnixNano())))
Expand Down
5 changes: 1 addition & 4 deletions extra/initial-data/models/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ type JsonCondition struct {

func (j *JsonConditions) AddCondition(condition Condition, isuId int) error {
jsonCondition := JsonCondition{
// JST分マイナスすると何故かちょうどよい
// DB上はJSTなのでUnixtimeはJST時間に変換されている(UTC時間+9表記)
// JST時間なのにどこかでTimezone情報なくなって時刻表記だけになる→UTCとして解釈される→JST環境では更に+9時間されて本来より9時間多い値になるとか?
condition.Timestamp.Add(-9 * time.Hour).Unix(),
condition.Timestamp.Unix(),
condition.IsSitting,
condition.IsDirty,
condition.IsOverweight,
Expand Down

0 comments on commit 7adf61b

Please sign in to comment.