From 56ad01f5a2cfc0413a30fc8684407828cab5a7f4 Mon Sep 17 00:00:00 2001 From: Yun Date: Sat, 22 Jun 2019 10:08:17 +0900 Subject: [PATCH 1/2] to remove difference in time calculation change all time object to UTC instance --- types/graded_account_test.go | 2 ++ types/lazy_graded_account_test.go | 2 ++ update/plan/update_230000.go | 4 ++-- update/plan/update_230000_test.go | 14 +++++++++++++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/types/graded_account_test.go b/types/graded_account_test.go index 13d01b014..8800f146e 100644 --- a/types/graded_account_test.go +++ b/types/graded_account_test.go @@ -41,6 +41,8 @@ func init() { panic(err) } + timeGenesis = timeGenesis.UTC() + monthlyTimes = []int64{} for i := 0; i < 4; i++ { for j := 0; j < 12; j++ { diff --git a/types/lazy_graded_account_test.go b/types/lazy_graded_account_test.go index f2a6ec7d1..418644be9 100644 --- a/types/lazy_graded_account_test.go +++ b/types/lazy_graded_account_test.go @@ -27,6 +27,8 @@ func init() { panic(err) } + timeGenesis = timeGenesis.UTC() + monthlyTimes = []int64{} for i := 0; i < 4; i++ { for j := 0; j < 12; j++ { diff --git a/update/plan/update_230000.go b/update/plan/update_230000.go index f61a8aa63..846859946 100644 --- a/update/plan/update_230000.go +++ b/update/plan/update_230000.go @@ -175,7 +175,7 @@ func updatePreseedSchedules(gvacc types.GradedVestingAccount) []types.LazyVestin var lazyVestingSchedule types.LazyVestingSchedule var lazySchedules []types.LazySchedule - genesisTime := time.Unix(genesisUnixTime, 0) + genesisTime := time.Unix(genesisUnixTime, 0).UTC() lazySchedules = append(lazySchedules, types.NewLazySchedule( genesisTime.AddDate(0, 1, 0).Unix(), genesisTime.AddDate(0, 2, 0).Unix(), sdk.NewDecWithPrec(10, 2)), @@ -251,7 +251,7 @@ func updateSeedSchedules(gvacc types.GradedVestingAccount) []types.LazyVestingSc var lazyVestingSchedule types.LazyVestingSchedule var lazySchedules []types.LazySchedule - genesisTime := time.Unix(genesisUnixTime, 0) + genesisTime := time.Unix(genesisUnixTime, 0).UTC() lazySchedules = append(lazySchedules, types.NewLazySchedule( genesisTime.AddDate(0, 1, 0).Unix(), genesisTime.AddDate(0, 2, 0).Unix(), ratio.Mul(sdk.NewDecWithPrec(10, 2))), diff --git a/update/plan/update_230000_test.go b/update/plan/update_230000_test.go index af2c23288..09e43c582 100644 --- a/update/plan/update_230000_test.go +++ b/update/plan/update_230000_test.go @@ -15,7 +15,7 @@ import ( ) var ( - genesisTime = time.Unix(1556085600, 0) + genesisTime = time.Unix(1556085600, 0).UTC() preseedSchedule types.VestingSchedule seedSchedule types.VestingSchedule @@ -244,6 +244,18 @@ func init() { } } +func TestTimeZone(t *testing.T) { + genesisTime := time.Unix(1556085600, 0) + location, _ := time.LoadLocation("Europe/Budapest") + genesisTime = genesisTime.In(location) + result := genesisTime.AddDate(0, 10, 0).Unix() + require.NotEqual(t, int64(1582524000), result) + + genesisTime = genesisTime.UTC() + result = genesisTime.AddDate(0, 10, 0).Unix() + require.Equal(t, int64(1582524000), result) +} + func TestPreseedAccountUpdate(t *testing.T) { for _, acc := range preseedAccounts { From a3c48e7b63fbd01da6d2bc9df2be9c4e0f0eb20f Mon Sep 17 00:00:00 2001 From: Yun Date: Sat, 22 Jun 2019 10:13:17 +0900 Subject: [PATCH 2/2] change log update --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 812d073e6..0f428c729 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## 0.2.3 +- [\#187](https://github.com/terra-project/core/pull/187): Change all time instance timezone to UTC to remove gap in time calculation + +### Changes +#### [\#187](https://github.com/terra-project/core/pull/187) Bugfix/fix-time-zone +In update_230000.go, we change genesis time derivation from +``` +genesisTime := time.Unix(genesisUnixTime, 0) +``` +to +``` +genesisTime := time.Unix(genesisUnixTime, 0).UTC() +``` + ## 0.2.2 - [\#185](https://github.com/terra-project/core/pull/185): Improve oracle specs