Skip to content

Commit

Permalink
Core,Lib(refactor): remove usage of GTimeVal
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverRainZ committed Sep 1, 2022
1 parent ac00f83 commit 3fa324d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/core/app_irc_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1051,14 +1051,14 @@ static void irc_event_ctcp_req(SircSession *sirc, const char *event,
} else if (strcmp(event, "SOURCE") == 0) {
sirc_cmd_ctcp_rsp(srv->irc, origin, event, PACKAGE_WEBSITE);
} else if (strcmp(event, "TIME") == 0) {
GTimeVal val;
g_get_current_time(&val);
GDateTime *val = g_date_time_new_now_local();
// ISO 8601 is recommend
char *time = g_time_val_to_iso8601(&val);
char *time = g_date_time_format_iso8601(val);
if (time){
sirc_cmd_ctcp_rsp(srv->irc, origin, event, time);
g_free(time);
}
g_date_time_unref(val);
} else if (strcmp(event, "VERSION") == 0) {
sirc_cmd_ctcp_rsp(srv->irc, origin, event,
PACKAGE_NAME " " PACKAGE_VERSION "-" PACKAGE_BUILD);
Expand Down
1 change: 0 additions & 1 deletion src/inc/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <srain.h>

unsigned long get_time_since_first_call_ms(void);
time_t get_current_time_s(void);
void time_to_str(time_t time, char *timestr, size_t size, const char *fmt);
void str_assign(char **left, const char *right);
bool str_is_empty(const char *str);
Expand Down
8 changes: 0 additions & 8 deletions src/lib/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ unsigned long get_time_since_first_call_ms(void){
return ret;
}

time_t get_current_time_s(void){
GTimeVal val;

g_get_current_time(&val);

return val.tv_sec + val.tv_usec / 1e6;
}

void time_to_str(time_t time, char *timestr, size_t size, const char *fmt){
strftime(timestr, size - 1, fmt, localtime(&time));

Expand Down

0 comments on commit 3fa324d

Please sign in to comment.