3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 02:32:39 +01:00

time.Unix still requires normalization to UTC

This commit is contained in:
Shivaram Lingamneni 2020-02-20 03:06:24 -05:00
parent 8031085c26
commit fab0630180
6 changed files with 10 additions and 10 deletions

View File

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

View File

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

View File

@ -9,9 +9,9 @@ import (
)
func TestZncTimestampParser(t *testing.T) {
assertEqual(zncWireTimeToTime("1558338348.988"), time.Unix(1558338348, 988000000), t)
assertEqual(zncWireTimeToTime("1558338348.9"), time.Unix(1558338348, 900000000), t)
assertEqual(zncWireTimeToTime("1558338348"), time.Unix(1558338348, 0), t)
assertEqual(zncWireTimeToTime(".988"), time.Unix(0, 988000000), t)
assertEqual(zncWireTimeToTime("garbage"), time.Unix(0, 0), t)
assertEqual(zncWireTimeToTime("1558338348.988"), time.Unix(1558338348, 988000000).UTC(), t)
assertEqual(zncWireTimeToTime("1558338348.9"), time.Unix(1558338348, 900000000).UTC(), t)
assertEqual(zncWireTimeToTime("1558338348"), time.Unix(1558338348, 0).UTC(), t)
assertEqual(zncWireTimeToTime(".988"), time.Unix(0, 988000000).UTC(), t)
assertEqual(zncWireTimeToTime("garbage"), time.Unix(0, 0).UTC(), t)
}

View File

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

View File

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

View File

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