aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/misc1.c
diff options
context:
space:
mode:
authorRob Pilling <robpilling@gmail.com>2020-03-22 21:40:12 +0000
committerRob Pilling <robpilling@gmail.com>2020-04-21 21:40:22 +0100
commit978a6bcaf2b98b3c89381a3eacf642b4f61db033 (patch)
tree29f26959683fa1f5b10feed3b086531777d1e9f6 /src/nvim/misc1.c
parent9d59f066cbbe8893559586eee5bfca9378cf6385 (diff)
downloadrneovim-978a6bcaf2b98b3c89381a3eacf642b4f61db033.tar.gz
rneovim-978a6bcaf2b98b3c89381a3eacf642b4f61db033.tar.bz2
rneovim-978a6bcaf2b98b3c89381a3eacf642b4f61db033.zip
vim-patch:8.1.2225: the "last used" info of a buffer is under used
Problem: The "last used" info of a buffer is under used. Solution: Add "lastused" to getbufinfo(). List buffers sorted by last-used field. (Andi Massimino, closes vim/vim#4722) https://github.com/vim/vim/commit/52410575be50d5c40bbe6380159df48cfc382ceb
Diffstat (limited to 'src/nvim/misc1.c')
-rw-r--r--src/nvim/misc1.c23
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);
+ }
+}