1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-06-30 03:56:45 +02:00

get unix time more efficiently

This commit is contained in:
Jfreegman
2014-03-13 23:56:46 -04:00
parent c2d417c78b
commit d29836845c
6 changed files with 35 additions and 19 deletions

View File

@ -33,6 +33,27 @@
extern ToxWindow *prompt;
static uint64_t current_unix_time;
void update_unix_time(void)
{
current_unix_time = (uint64_t) time(NULL);
}
uint64_t get_unix_time(void)
{
return current_unix_time;
}
/* Get the current local time */
struct tm *get_time(void)
{
struct tm *timeinfo;
uint64_t t = get_unix_time();
timeinfo = localtime(&t);
return timeinfo;
}
/* XXX: FIX */
unsigned char *hex_string_to_bin(char hex_string[])
{
@ -54,16 +75,6 @@ unsigned char *hex_string_to_bin(char hex_string[])
return val;
}
/* Get the current local time */
struct tm *get_time(void)
{
struct tm *timeinfo;
time_t now;
time(&now);
timeinfo = localtime(&now);
return timeinfo;
}
/* Prints the time to given window */
void print_time(WINDOW *window)
{