Fixes against weekly.2012-02-22

Convert time/duration variables
Clean up duration math
This commit is contained in:
Michael Jard
2012-02-25 00:52:19 -08:00
parent 4e661a3954
commit a0256382be
3 changed files with 19 additions and 15 deletions

View File

@@ -1,10 +1,10 @@
package irc
import (
"strings"
"fmt"
"time"
"strconv"
"strings"
"time"
)
func (irc *IRCConnection) AddCallback(eventcode string, callback func(*IRCEvent)) {
@@ -80,7 +80,7 @@ func (irc *IRCConnection) setupCallbacks() {
})
irc.AddCallback("CTCP_TIME", func(e *IRCEvent) {
ltime := time.LocalTime()
ltime := time.Now()
irc.SendRaw(fmt.Sprintf("NOTICE %s :\x01TIME %s\x01", e.Nick, ltime.String()))
})
@@ -101,8 +101,9 @@ func (irc *IRCConnection) setupCallbacks() {
})
irc.AddCallback("PONG", func(e *IRCEvent) {
ns, _ := strconv.Atoi64(e.Message)
fmt.Printf("Lag: %fs\n", float32((time.Nanoseconds()-ns))/1000/1000/1000)
ns, _ := strconv.ParseInt(e.Message, 10, 64)
delta := time.Duration(time.Now().UnixNano() - ns)
fmt.Printf("Lag: %vs\n", delta)
})
irc.AddCallback("NICK", func(e *IRCEvent) {