Quellcode durchsuchen

time.Unix still requires normalization to UTC

tags/v2.0.0-rc1
Shivaram Lingamneni vor 4 Jahren
Ursprung
Commit
fab0630180
6 geänderte Dateien mit 10 neuen und 10 gelöschten Zeilen
  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 Datei anzeigen

560
 	})
560
 	})
561
 	lsNum, err := strconv.ParseInt(lsText, 10, 64)
561
 	lsNum, err := strconv.ParseInt(lsText, 10, 64)
562
 	if err != nil {
562
 	if err != nil {
563
-		return time.Unix(0, lsNum)
563
+		return time.Unix(0, lsNum).UTC()
564
 	}
564
 	}
565
 	return
565
 	return
566
 }
566
 }

+ 1
- 1
irc/channelreg.go Datei anzeigen

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

+ 5
- 5
irc/misc_test.go Datei anzeigen

9
 )
9
 )
10
 
10
 
11
 func TestZncTimestampParser(t *testing.T) {
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 Datei anzeigen

405
 	if mysql.logError("could not resolve msgid to time", err) {
405
 	if mysql.logError("could not resolve msgid to time", err) {
406
 		return
406
 		return
407
 	}
407
 	}
408
-	result = time.Unix(0, nanotime)
408
+	result = time.Unix(0, nanotime).UTC()
409
 	return
409
 	return
410
 }
410
 }
411
 
411
 

+ 1
- 1
irc/utils/args.go Datei anzeigen

80
 }
80
 }
81
 
81
 
82
 func NanoToTimestamp(nanotime int64) string {
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 Datei anzeigen

45
 	}
45
 	}
46
 	seconds, _ := strconv.ParseInt(secondsPortion, 10, 64)
46
 	seconds, _ := strconv.ParseInt(secondsPortion, 10, 64)
47
 	fraction, _ := strconv.ParseFloat(fracPortion, 64)
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
 type zncPlaybackTimes struct {
51
 type zncPlaybackTimes struct {

Laden…
Abbrechen
Speichern