Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
MuggleWei committed Sep 4, 2023
2 parents 6fbad14 + 1c13fa9 commit 7490840
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/yoauth/exe/handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,15 @@ void yoauth_handle_destroy(yoauth_handle_t *handle)
handle->datas = NULL;
}

static char *yoauth_handle_datetime(time_t ts, char *buf, size_t bufsize)
{
struct tm t;
localtime_r(&ts, &t);
snprintf(buf, bufsize, "%d-%02d-%02dT%02d:%02d:%02d", t.tm_year + 1900,
t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
return buf;
}

void yoauth_handle_list(yoauth_handle_t *handle, const char *filter)
{
time_t ts = time(NULL);
Expand All @@ -240,6 +249,15 @@ void yoauth_handle_list(yoauth_handle_t *handle, const char *filter)

YOAUTH_OUTPUT_KV(data->account, v, 42);
}

time_t next_step_ts = ((time_t)(ts / 30 + 1) * 30);
char curr_tm[64];
yoauth_handle_datetime(ts, curr_tm, sizeof(curr_tm));

YOAUTH_OUTPUT_SPLIT_LINE;
time_t expired_sec = next_step_ts - ts;
YOAUTH_TIP("current: %s\nexpire after %llu seconds", curr_tm,
(unsigned long long)expired_sec);
}

static int cmp_totp_data(const void *d1, const void *d2)
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.9
1.0.10

0 comments on commit 7490840

Please sign in to comment.