Fixes against weekly.2012-02-22
Convert time/duration variables Clean up duration math
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user