浏览代码

time.Unix still requires normalization to UTC

tags/v2.0.0-rc1
Shivaram Lingamneni 4 年前
父节点
当前提交
fab0630180
共有 6 个文件被更改,包括 10 次插入10 次删除
  1. 1
    1
      irc/accounts.go
  2. 1
    1
      irc/channelreg.go
  3. 5
    5
      irc/misc_test.go
  4. 1
    1
      irc/mysql/history.go
  5. 1
    1
      irc/utils/args.go
  6. 1
    1
      irc/znc.go

+ 1
- 1
irc/accounts.go 查看文件

@@ -560,7 +560,7 @@ func (am *AccountManager) loadLastSignoff(account string) (lastSignoff time.Time
560 560
 	})
561 561
 	lsNum, err := strconv.ParseInt(lsText, 10, 64)
562 562
 	if err != nil {
563
-		return time.Unix(0, lsNum)
563
+		return time.Unix(0, lsNum).UTC()
564 564
 	}
565 565
 	return
566 566
 }

+ 1
- 1
irc/channelreg.go 查看文件

@@ -271,7 +271,7 @@ func (reg *ChannelRegistry) deleteChannel(tx *buntdb.Tx, key string, info Regist
271 271
 	if err == nil {
272 272
 		regTime, _ := tx.Get(fmt.Sprintf(keyChannelRegTime, key))
273 273
 		regTimeInt, _ := strconv.ParseInt(regTime, 10, 64)
274
-		registeredAt := time.Unix(regTimeInt, 0)
274
+		registeredAt := time.Unix(regTimeInt, 0).UTC()
275 275
 		founder, _ := tx.Get(fmt.Sprintf(keyChannelFounder, key))
276 276
 
277 277
 		// to see if we're deleting the right channel, confirm the founder and the registration time

+ 5
- 5
irc/misc_test.go 查看文件

@@ -9,9 +9,9 @@ import (
9 9
 )
10 10
 
11 11
 func TestZncTimestampParser(t *testing.T) {
12
-	assertEqual(zncWireTimeToTime("1558338348.988"), time.Unix(1558338348, 988000000), t)
13
-	assertEqual(zncWireTimeToTime("1558338348.9"), time.Unix(1558338348, 900000000), t)
14
-	assertEqual(zncWireTimeToTime("1558338348"), time.Unix(1558338348, 0), t)
15
-	assertEqual(zncWireTimeToTime(".988"), time.Unix(0, 988000000), t)
16
-	assertEqual(zncWireTimeToTime("garbage"), time.Unix(0, 0), t)
12
+	assertEqual(zncWireTimeToTime("1558338348.988"), time.Unix(1558338348, 988000000).UTC(), t)
13
+	assertEqual(zncWireTimeToTime("1558338348.9"), time.Unix(1558338348, 900000000).UTC(), t)
14
+	assertEqual(zncWireTimeToTime("1558338348"), time.Unix(1558338348, 0).UTC(), t)
15
+	assertEqual(zncWireTimeToTime(".988"), time.Unix(0, 988000000).UTC(), t)
16
+	assertEqual(zncWireTimeToTime("garbage"), time.Unix(0, 0).UTC(), t)
17 17
 }

+ 1
- 1
irc/mysql/history.go 查看文件

@@ -405,7 +405,7 @@ func (mysql *MySQL) msgidToTime(msgid string) (result time.Time, err error) {
405 405
 	if mysql.logError("could not resolve msgid to time", err) {
406 406
 		return
407 407
 	}
408
-	result = time.Unix(0, nanotime)
408
+	result = time.Unix(0, nanotime).UTC()
409 409
 	return
410 410
 }
411 411
 

+ 1
- 1
irc/utils/args.go 查看文件

@@ -80,5 +80,5 @@ func (err *IncompatibleSchemaError) Error() string {
80 80
 }
81 81
 
82 82
 func NanoToTimestamp(nanotime int64) string {
83
-	return time.Unix(0, nanotime).Format(IRCv3TimestampFormat)
83
+	return time.Unix(0, nanotime).UTC().Format(IRCv3TimestampFormat)
84 84
 }

+ 1
- 1
irc/znc.go 查看文件

@@ -45,7 +45,7 @@ func zncWireTimeToTime(str string) (result time.Time) {
45 45
 	}
46 46
 	seconds, _ := strconv.ParseInt(secondsPortion, 10, 64)
47 47
 	fraction, _ := strconv.ParseFloat(fracPortion, 64)
48
-	return time.Unix(seconds, int64(fraction*1000000000))
48
+	return time.Unix(seconds, int64(fraction*1000000000)).UTC()
49 49
 }
50 50
 
51 51
 type zncPlaybackTimes struct {

正在加载...
取消
保存