summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
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()
s@users.noreply.github.com> 2020-04-20 15:09:59 +0000 committer GitHub <noreply@github.com> 2020-04-20 17:09:59 +0200 Make file descriptors from stdlib non-inheritable by default (#13201)' href='/ahoang/Nim/commit/changelog.md?h=devel&id=1bdc30bdb13422bd5eff830327582a938e7b76ac'>1bdc30bdb ^
4ae341353 ^




1bdc30bdb ^




4ae341353 ^


1bdc30bdb ^


9134bb9cf ^
cc60caedb ^


d5d359445 ^
cc60caedb ^
7ce035835 ^




cd9af6b80 ^




03c146cd9 ^
cd9af6b80 ^


03c146cd9 ^
cd9af6b80 ^
caf30e7cb ^


7ce035835 ^
d23446c6b ^

a3a317b76 ^

b8e6ea754 ^



3e060cfb0 ^


03c146cd9 ^
3e060cfb0 ^










48e7775ad ^




3e060cfb0 ^
d11cb9d49 ^


06dfd3161 ^
7f377da1d ^
06dfd3161 ^
041ee92bb ^


1fb2a5867 ^


256841cf2 ^
1fb2a5867 ^




c7a1a7b8b ^

6aa971d39 ^
82e424189 ^
bf604c682 ^
9c42ae91b ^
82e424189 ^
6aa971d39 ^
b70fd0400 ^
03c146cd9 ^

9295251e6 ^


























5db0bb744 ^
dd24004fa ^

9acbf99ef ^

de27910ab ^
03c146cd9 ^























00fa7a574 ^

7d17cd34b ^
f7d2f9c5f ^
9c46927fa ^
a890aa75a ^
c777f2fb6 ^

5c534b294 ^








411be506a ^


dda6f3f6d ^
3573a4f9c ^


c777f2fb6 ^





3d20f1419 ^

58282547f ^


737fff590 ^
7d17cd34b ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214