summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-09-24 00:46:54 +0200
committerAraq <rumpf_a@web.de>2011-09-24 00:46:54 +0200
commit3824b6ea5f320f956473bdfaf0894fe89c90f0ab (patch)
tree6185dd432665cff1596e4a85bf1f6c43229570be /lib/pure
parent6023e994fbc949c77abbbe4ffae761ca982732db (diff)
parent6deda5a973312e86fe58e319e97afd93bc07c82d (diff)
downloadNim-3824b6ea5f320f956473bdfaf0894fe89c90f0ab.tar.gz
Merge branch 'master' of git@github.com:Araq/Nimrod
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/irc.nim8
-rwxr-xr-xlib/pure/times.nim8
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/pure/irc.nim b/lib/pure/irc.nim
index 5a4c815f6..0397502cd 100644
--- a/lib/pure/irc.nim
+++ b/lib/pure/irc.nim
@@ -70,7 +70,12 @@ type
   
 proc send*(irc: var TIRC, message: string) =
   ## Sends ``message`` as a raw command. It adds ``\c\L`` for you.
-  irc.sock.send(message & "\c\L")
+  try:
+    irc.sock.send(message & "\c\L")
+  except EOS:
+    # Assuming disconnection of every EOS could be bad,
+    # but I can't exactly check for EBrokenPipe.
+    irc.connected = false
 
 proc privmsg*(irc: var TIRC, target, message: string) =
   ## Sends ``message`` to ``target``. ``Target`` can be a channel, or a user.
@@ -199,6 +204,7 @@ proc poll*(irc: var TIRC, ev: var TIRCEvent,
   ##
   ## This function should be called often as it also handles pinging
   ## the server.
+  if not irc.connected: ev.typ = EvDisconnected
   var line = ""
   var socks = @[irc.sock]
   var ret = socks.select(timeout)
diff --git a/lib/pure/times.nim b/lib/pure/times.nim
index da23d4615..378d6ae80 100755
--- a/lib/pure/times.nim
+++ b/lib/pure/times.nim
@@ -52,7 +52,7 @@ elif defined(windows):
 
 elif defined(ECMAScript):
   type
-    TTime* {.final.} = object
+    TTime* {.final, importc.} = object
       getDay: proc (): int
       getFullYear: proc (): int
       getHours: proc (): int
@@ -62,6 +62,7 @@ elif defined(ECMAScript):
       getSeconds: proc (): int
       getTime: proc (): int
       getTimezoneOffset: proc (): int
+      getDate: proc (): int
       getUTCDate: proc (): int
       getUTCFullYear: proc (): int
       getUTCHours: proc (): int
@@ -310,7 +311,8 @@ when not defined(ECMAScript):
       result = toFloat(int(clock())) / toFloat(clocksPerSec)
     
 else:
-  proc getTime(): TTime {.importc: "new Date", nodecl.}
+  proc newDate(): TTime {.importc: "new Date", nodecl.}
+  proc getTime(): TTime = return newDate()
 
   const
     weekDays: array [0..6, TWeekDay] = [
@@ -346,7 +348,7 @@ else:
     result.setDate(timeInfo.monthday)
   
   proc `$`(timeInfo: TTimeInfo): string = return $(TimeInfoToTIme(timeInfo))
-  proc `$`(time: TTime): string = $time.toLocaleString()
+  proc `$`(time: TTime): string = return $time.toLocaleString()
     
   proc `-` (a, b: TTime): int64 = 
     return a.getTime() - b.getTime()