]>
jfr.im git - irc/quakenet/newserv.git/blob - miscreply/time.c
4 #include "../irc/irc.h"
5 #include "../core/error.h"
12 * Return the current date in the following format:
13 * "Day Month DD YYYY -- HH:MM +/-HH:MM"
14 * e.g. "Saturday March 27 2010 -- 19:03 +01:00"
15 * where the last part is the timezone offset
18 static char *timelongdate(void) {
33 n
= strftime(buf
, sizeof(buf
) - 8, "%A %B %e %Y -- %H:%M", tmp
);
47 off
= (unsigned int) (gt
- lt
);
50 off
= (unsigned int) (lt
- gt
);
53 off
= (off
/ 60) % 6000;
54 sprintf(&buf
[n
], " %c%02u:%02u", c
, off
/ 60, off
% 60);
61 /* handle remote time request
63 * <source numeric> TIME/TI <target server numeric>
65 * cargv[0] = target server numeric
66 * can be a * in which case the request is for all servers (snircd extension)
69 int handletimemsg(void *source
, int cargc
, char **cargv
) {
71 nick
*snick
; /* struct nick for source nick */
72 long unsigned int timestamp
= getnettime(); /* current nettime */
73 long unsigned int offset
= timestamp
- time(NULL
); /* offset nettime to system clock */
74 char *sourcenum
= (char *)source
; /* source user numeric */
76 /* check parameters */
78 miscreply_needmoreparams(sourcenum
, "TIME");
82 /* find source user */
83 if (!(snick
= miscreply_finduser(sourcenum
, "TIME")))
87 * 391 RPL_TIME "source 391 target servername timestamp offset :longdate"
88 * "irc.netsplit.net 391 foobar irc.netsplit.net 1269713493 0 :Saturday March 27 2010 -- 19:11 +01:00"
90 irc_send("%s 391 %s %s %lu %ld :%s", getmynumeric(), sourcenum
, myserver
->content
, timestamp
, offset
, timelongdate());