@@ -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
4045void 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-
479485json_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