@@ -32,11 +32,23 @@ void json_pack_peer_type (json_t *res, tgl_peer_id_t id) {
32
32
}
33
33
}
34
34
35
+ int str_format_time (long when , char * string )
36
+ {
37
+ struct tm * tm = localtime ((void * )& when );
38
+ 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 );
39
+ }
35
40
36
41
void json_pack_user (json_t * res , tgl_peer_t * P ) {
37
42
if (P -> user .first_name ) {
38
43
assert (json_object_set (res , "first_name" , json_string (P -> user .first_name )) >= 0 );
39
44
}
45
+
46
+ if (P -> user .status .when ) {
47
+ static char s [20 ];
48
+ str_format_time (P -> user .status .when , s );
49
+ assert (json_object_set (res , "when" , json_string (s )) >= 0 );
50
+ }
51
+
40
52
if (P -> user .last_name ) {
41
53
assert (json_object_set (res , "last_name" , json_string (P -> user .last_name )) >= 0 );
42
54
}
@@ -436,12 +448,6 @@ json_t *json_pack_read (struct tgl_message *M) {
436
448
return res ;
437
449
}
438
450
439
- int str_format_time (long when , char * string )
440
- {
441
- struct tm * tm = localtime ((void * )& when );
442
- 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 );
443
- }
444
-
445
451
json_t * json_pack_user_status (struct tgl_user * U ) {
446
452
json_t * res = json_object ();
447
453
assert (json_object_set (res , "user" , json_pack_peer (U -> id )) >= 0 );
0 commit comments