Skip to content

Commit ddaf004

Browse files
committed
presence: subs_phtable_list - print expires attr in human readable format
1 parent 6ac1dc8 commit ddaf004

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

modules/presence/presence.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,9 @@ static inline int mi_print_shtable_record(struct mi_node *rpl, subs_t* s)
690690
{
691691
struct mi_node *node, *node1;
692692
struct mi_attr *attr;
693+
time_t _ts;
694+
char date_buf[MI_DATE_BUF_LEN];
695+
int date_buf_len;
693696
char *p;
694697
int len;
695698

@@ -701,11 +704,16 @@ static inline int mi_print_shtable_record(struct mi_node *rpl, subs_t* s)
701704
attr = add_mi_attr(node, MI_DUP_VALUE, "event_id", 8, s->event_id.s, s->event_id.len);
702705
if (attr==NULL) goto error;
703706
*/
704-
p= int2str((unsigned long)s->status, &len);
705-
attr = add_mi_attr(node, MI_DUP_VALUE, "status", 6, p, len);
706707
if (attr==NULL) goto error;
707-
p= int2str((unsigned long)s->expires, &len);
708-
attr = add_mi_attr(node, MI_DUP_VALUE, "expires", 7, p, len);
708+
_ts = (time_t)s->expires;
709+
date_buf_len = strftime(date_buf, MI_DATE_BUF_LEN - 1,
710+
"%Y-%m-%d %H:%M:%S", localtime(&_ts));
711+
if (date_buf_len != 0) {
712+
attr = add_mi_attr(node, MI_DUP_VALUE, "expires", 7, date_buf, date_buf_len);
713+
} else {
714+
p= int2str((unsigned long)s->expires, &len);
715+
attr = add_mi_attr(node, MI_DUP_VALUE, "expires", 7, p, len);
716+
}
709717
if (attr==NULL) goto error;
710718
p= int2str((unsigned long)s->db_flag, &len);
711719
attr = add_mi_attr(node, MI_DUP_VALUE, "db_flag", 7, p, len);

0 commit comments

Comments
 (0)