Browse Source

server ctime

tags/v0.1.0
Jeremy Latt 12 years ago
parent
commit
259fd40916
3 changed files with 7 additions and 3 deletions
  1. 1
    1
      src/irc/commands.go
  2. 3
    2
      src/irc/responses.go
  3. 3
    0
      src/irc/server.go

+ 1
- 1
src/irc/commands.go View File

@@ -65,7 +65,7 @@ func tryRegister(s *Server, c *Client) {
65 65
 		c.registered = true
66 66
 		c.send <- ReplyWelcome(c)
67 67
 		c.send <- ReplyYourHost(c.Nick(), s.name)
68
-		c.send <- ReplyCreated(c.Nick(), "2012/04/07")
68
+		c.send <- ReplyCreated(c.Nick(), s.ctime)
69 69
 		c.send <- ReplyMyInfo(c.Nick(), s.name)
70 70
 	}
71 71
 }

+ 3
- 2
src/irc/responses.go View File

@@ -2,6 +2,7 @@ package irc
2 2
 
3 3
 import (
4 4
 	"fmt"
5
+	"time"
5 6
 )
6 7
 
7 8
 func ReplyNick(oldNick string, c *Client) string {
@@ -16,8 +17,8 @@ func ReplyYourHost(nick string, server string) string {
16 17
 	return fmt.Sprintf("%s %s Your host is %s, running version %s", RPL_YOURHOST, nick, server, VERSION)
17 18
 }
18 19
 
19
-func ReplyCreated(nick string, created string) string {
20
-	return fmt.Sprintf("%s %s This server was created %s", RPL_CREATED, nick, created)
20
+func ReplyCreated(nick string, ctime time.Time) string {
21
+	return fmt.Sprintf("%s %s This server was created %s", RPL_CREATED, nick, ctime.Format(time.RFC1123))
21 22
 }
22 23
 
23 24
 func ReplyMyInfo(nick string, servername string) string {

+ 3
- 0
src/irc/server.go View File

@@ -3,9 +3,11 @@ package irc
3 3
 import (
4 4
 	"log"
5 5
 	"net"
6
+	"time"
6 7
 )
7 8
 
8 9
 type Server struct {
10
+	ctime time.Time
9 11
 	name string
10 12
 	ch chan *ClientMessage
11 13
 	nicks map[string]*Client
@@ -18,6 +20,7 @@ type ClientMessage struct {
18 20
 
19 21
 func NewServer(name string) *Server {
20 22
 	server := new(Server)
23
+	server.ctime = time.Now()
21 24
 	server.name = name
22 25
 	server.ch = make(chan *ClientMessage)
23 26
 	server.nicks = make(map[string]*Client)

Loading…
Cancel
Save