diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2020-04-26 23:57:37 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-26 23:57:37 -0400 |
commit | 34ad1ea36637845adb14c579587168126d3210e3 (patch) | |
tree | 7342478885db7348b3925739f5a0320b48121102 /src/nvim/misc1.c | |
parent | 5f41717838f4cd9d1087e452640ba554500279ab (diff) | |
parent | 978a6bcaf2b98b3c89381a3eacf642b4f61db033 (diff) | |
download | rneovim-34ad1ea36637845adb14c579587168126d3210e3.tar.gz rneovim-34ad1ea36637845adb14c579587168126d3210e3.tar.bz2 rneovim-34ad1ea36637845adb14c579587168126d3210e3.zip |
Merge #12155 ':ls filter by terminal, lastused'
Diffstat (limited to 'src/nvim/misc1.c')
-rw-r--r-- | src/nvim/misc1.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index e7fb38e801..e10770b6bd 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -1162,3 +1162,26 @@ int goto_im(void) { return p_im && stuff_empty() && typebuf_typed(); } + +/// Put the timestamp of an undo header in "buf[buflen]" in a nice format. +void add_time(char_u *buf, size_t buflen, time_t tt) +{ + struct tm curtime; + + if (time(NULL) - tt >= 100) { + os_localtime_r(&tt, &curtime); + if (time(NULL) - tt < (60L * 60L * 12L)) { + // within 12 hours + (void)strftime((char *)buf, buflen, "%H:%M:%S", &curtime); + } else { + // longer ago + (void)strftime((char *)buf, buflen, "%Y/%m/%d %H:%M:%S", &curtime); + } + } else { + int64_t seconds = time(NULL) - tt; + vim_snprintf((char *)buf, buflen, + NGETTEXT("%" PRId64 " second ago", + "%" PRId64 " seconds ago", (uint32_t)seconds), + seconds); + } +} |