Mercurial > vim
comparison src/misc1.c @ 19396:a961efb326e5 v8.2.0256
patch 8.2.0256: time and timer related code is spread out
Commit: https://github.com/vim/vim/commit/0a8fed6231c84e4e1b3a7dd6c0d95d3f98207fe0
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 14 13:22:17 2020 +0100
patch 8.2.0256: time and timer related code is spread out
Problem: Time and timer related code is spread out.
Solution: Move time and timer related code to a new file. (Yegappan
Lakshmanan, closes #5604)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 14 Feb 2020 13:30:05 +0100 |
parents | 9dc843109c97 |
children | 22f0dda71638 |
comparison
equal
deleted
inserted
replaced
19395:eb5ef6f5f58b | 19396:a961efb326e5 |
---|---|
2595 | 2595 |
2596 for (p = fname; isalpha(*p); ++p) | 2596 for (p = fname; isalpha(*p); ++p) |
2597 ; | 2597 ; |
2598 return path_is_url(p); | 2598 return path_is_url(p); |
2599 } | 2599 } |
2600 | |
2601 /* | |
2602 * Put timestamp "tt" in "buf[buflen]" in a nice format. | |
2603 */ | |
2604 void | |
2605 add_time(char_u *buf, size_t buflen, time_t tt) | |
2606 { | |
2607 #ifdef HAVE_STRFTIME | |
2608 struct tm tmval; | |
2609 struct tm *curtime; | |
2610 | |
2611 if (vim_time() - tt >= 100) | |
2612 { | |
2613 curtime = vim_localtime(&tt, &tmval); | |
2614 if (vim_time() - tt < (60L * 60L * 12L)) | |
2615 // within 12 hours | |
2616 (void)strftime((char *)buf, buflen, "%H:%M:%S", curtime); | |
2617 else | |
2618 // longer ago | |
2619 (void)strftime((char *)buf, buflen, "%Y/%m/%d %H:%M:%S", curtime); | |
2620 } | |
2621 else | |
2622 #endif | |
2623 { | |
2624 long seconds = (long)(vim_time() - tt); | |
2625 | |
2626 vim_snprintf((char *)buf, buflen, | |
2627 NGETTEXT("%ld second ago", "%ld seconds ago", seconds), | |
2628 seconds); | |
2629 } | |
2630 } |