add preliminary timeformat to chat windows
This commit is contained in:
parent
f9db598e16
commit
24e3cb62bc
@ -21,6 +21,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <jansson.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <dc/account.h>
|
||||
|
||||
@ -37,6 +38,7 @@ char const *dc_message_channel_id(dc_message_t m);
|
||||
char const *dc_message_timestamp(dc_message_t m);
|
||||
char const *dc_message_content(dc_message_t m);
|
||||
dc_account_t dc_message_author(dc_message_t m);
|
||||
time_t dc_message_unix_timestamp(dc_message_t m);
|
||||
|
||||
int dc_message_compare(dc_message_t *a, dc_message_t *b);
|
||||
|
||||
|
@ -153,6 +153,12 @@ static void dc_message_parse_timestamp(dc_message_t m)
|
||||
m->ts = timegm(&t);
|
||||
}
|
||||
|
||||
time_t dc_message_unix_timestamp(dc_message_t m)
|
||||
{
|
||||
return_if_true(m == NULL, 0);
|
||||
return m->ts;
|
||||
}
|
||||
|
||||
int dc_message_compare(dc_message_t *a, dc_message_t *b)
|
||||
{
|
||||
return_if_true(a == NULL || *a == NULL ||
|
||||
|
@ -183,10 +183,13 @@ ncdc_textview_render_par(ncdc_textview_t v, WINDOW *win, int lines, int cols)
|
||||
static wchar_t *ncdc_textview_format(dc_message_t m)
|
||||
{
|
||||
wchar_t *c = NULL, *author = NULL, *message = NULL;
|
||||
wchar_t timestamp[100] = {0};
|
||||
size_t clen = 0;
|
||||
FILE *f = open_wmemstream(&c, &clen);
|
||||
wchar_t *ret = NULL;
|
||||
dc_account_t a = dc_message_author(m);
|
||||
struct tm *tm = NULL;
|
||||
time_t uts = 0;
|
||||
|
||||
return_if_true(f == NULL, NULL);
|
||||
|
||||
@ -196,7 +199,11 @@ static wchar_t *ncdc_textview_format(dc_message_t m)
|
||||
message = s_convert(dc_message_content(m));
|
||||
goto_if_true(message == NULL, cleanup);
|
||||
|
||||
fwprintf(f, L"< %ls> %ls", author, message);
|
||||
uts = dc_message_unix_timestamp(m);
|
||||
tm = gmtime(&uts);
|
||||
wcsftime(timestamp, 99, L"%F/%H:%M", tm);
|
||||
|
||||
fwprintf(f, L"%ls < %ls> %ls", timestamp, author, message);
|
||||
|
||||
fclose(f);
|
||||
f = NULL;
|
||||
|
4
todo.org
4
todo.org
@ -1,9 +1,9 @@
|
||||
* General
|
||||
** TODO move key handling away from the thread the event_loop thread
|
||||
* Channels [3/4]
|
||||
* Channels [4/4]
|
||||
** DONE Automatically open window for 1:1 and 1:N
|
||||
** DONE send v6/api/channels/$ID/ack for "I read that shit"
|
||||
** TODO add timestamps from messages
|
||||
** DONE add timestamps from messages
|
||||
** DONE add message sending
|
||||
* Guilds [2/3]
|
||||
** DONE Guild support code
|
||||
|
Loading…
Reference in New Issue
Block a user