Skip to content

Commit 6547c0b

Browse files
author
V V
committed
Merge github.com:vysheng/tg
2 parents 443793d + 160231b commit 6547c0b

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ compiler:
55
- clang
66

77
install:
8+
- sudo apt-get update
89
- sudo apt-get install libconfig8-dev
910
- sudo apt-get install libreadline6-dev
1011
- sudo apt-get install libssl-dev
@@ -17,3 +18,4 @@ script:
1718
- git submodule update --init --recursive
1819
- ./configure
1920
- make
21+

json-tg.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,23 @@ void json_pack_peer_type (json_t *res, tgl_peer_id_t id) {
3636
}
3737
}
3838

39+
int str_format_time(long when, char* string)
40+
{
41+
struct tm *tm = localtime ((void *)&when);
42+
return sprintf (string, "%04d-%02d-%02d %02d:%02d:%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
43+
}
3944

4045
void json_pack_user (json_t *res, tgl_peer_t *P) {
4146
if (P->user.first_name) {
4247
assert (json_object_set (res, "first_name", json_string (P->user.first_name)) >= 0);
4348
}
49+
50+
if (P->user.status.when) {
51+
static char s[20];
52+
str_format_time(P->user.status.when, s);
53+
assert (json_object_set (res, "when", json_string (s)) >= 0);
54+
}
55+
4456
if (P->user.last_name) {
4557
assert (json_object_set (res, "last_name", json_string (P->user.last_name)) >= 0);
4658
}
@@ -470,12 +482,6 @@ json_t *json_pack_read (struct tgl_message *M) {
470482
return res;
471483
}
472484

473-
int str_format_time(long when, char* string)
474-
{
475-
struct tm *tm = localtime ((void *)&when);
476-
return sprintf (string, "%04d-%02d-%02d %02d:%02d:%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
477-
}
478-
479485
json_t *json_pack_user_status (struct tgl_user *U) {
480486
json_t *res = json_object ();
481487
assert (json_object_set (res, "user", json_pack_peer (U->id)) >= 0);

0 commit comments

Comments
 (0)