Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
0a23e238
Commit
0a23e238
authored
Nov 30, 2015
by
vysheng
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #846 from mfuentesg/master
use str_format_time function on user_info command
parents
3a898a42
681b8e79
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
json-tg.c
json-tg.c
+12
-6
No files found.
json-tg.c
View file @
0a23e238
...
...
@@ -32,11 +32,23 @@ void json_pack_peer_type (json_t *res, tgl_peer_id_t id) {
}
}
int
str_format_time
(
long
when
,
char
*
string
)
{
struct
tm
*
tm
=
localtime
((
void
*
)
&
when
);
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
);
}
void
json_pack_user
(
json_t
*
res
,
tgl_peer_t
*
P
)
{
if
(
P
->
user
.
first_name
)
{
assert
(
json_object_set
(
res
,
"first_name"
,
json_string
(
P
->
user
.
first_name
))
>=
0
);
}
if
(
P
->
user
.
status
.
when
)
{
static
char
s
[
20
];
str_format_time
(
P
->
user
.
status
.
when
,
s
);
assert
(
json_object_set
(
res
,
"when"
,
json_string
(
s
))
>=
0
);
}
if
(
P
->
user
.
last_name
)
{
assert
(
json_object_set
(
res
,
"last_name"
,
json_string
(
P
->
user
.
last_name
))
>=
0
);
}
...
...
@@ -436,12 +448,6 @@ json_t *json_pack_read (struct tgl_message *M) {
return
res
;
}
int
str_format_time
(
long
when
,
char
*
string
)
{
struct
tm
*
tm
=
localtime
((
void
*
)
&
when
);
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
);
}
json_t
*
json_pack_user_status
(
struct
tgl_user
*
U
)
{
json_t
*
res
=
json_object
();
assert
(
json_object_set
(
res
,
"user"
,
json_pack_peer
(
U
->
id
))
>=
0
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment