vim-patch:8.1.2326: cannot parse a date/time string

Problem:    Cannot parse a date/time string.
Solution:   Add strptime(). (Stephen Wall, closes #)
10455d43fe

N/A patches for version.c:

vim-patch:8.1.2344: Cygwin: warning for using strptime()

Problem:    Cygwin: warning for using strptime().
Solution:   Move defining _XOPEN_SOURCE and __USE_XOPEN to vim.h. (Ken Takata,
            closes vim/vim#5265)  Use 700 for _XOPEN_SOURCE for mkdtemp().
6a228c6463
This commit is contained in:
Jan Edmund Lazo
2020-12-06 01:15:43 -05:00
parent 75a9db5b7d
commit 3261ba98a2
8 changed files with 108 additions and 8 deletions

View File

@@ -196,6 +196,22 @@ char *os_ctime(char *result, size_t result_len)
return os_ctime_r(&rawtime, result, result_len);
}
/// Portable version of POSIX strptime()
///
/// @param str[in] string to convert
/// @param format[in] format to parse "str"
/// @param tm[out] time representation of "str"
/// @return Pointer to first unprocessed character or NULL
char *os_strptime(const char *str, const char *format, struct tm *tm)
FUNC_ATTR_NONNULL_ALL
{
#ifdef HAVE_STRPTIME
return strptime(str, format, tm);
#else
return NULL;
#endif
}
/// Obtains the current Unix timestamp.
///
/// @return Seconds since epoch.