From 3261ba98a2c0f7644bbaf7890a3906c42cfdb807 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 6 Dec 2020 01:15:43 -0500 Subject: vim-patch:8.1.2326: cannot parse a date/time string Problem: Cannot parse a date/time string. Solution: Add strptime(). (Stephen Wall, closes #) https://github.com/vim/vim/commit/10455d43fef041309ce0613fa792c635dd71e3a8 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(). https://github.com/vim/vim/commit/6a228c6463935a73c8f21142cb7368545cfee317 --- src/nvim/testdir/test_functions.vim | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 5dae8d681a..5efd27d016 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1,5 +1,7 @@ " Tests for various functions. + source shared.vim +source check.vim " Must be done first, since the alternate buffer must be unset. func Test_00_bufexists() @@ -171,9 +173,8 @@ func Test_str2nr() endfunc func Test_strftime() - if !exists('*strftime') - return - endif + CheckFunction strftime + " Format of strftime() depends on system. We assume " that basic formats tested here are available and " identical on all systems which support strftime(). @@ -214,6 +215,28 @@ func Test_strftime() endif endfunc +func Test_strptime() + CheckFunction strptime + + if exists('$TZ') + let tz = $TZ + endif + let $TZ = 'UTC' + + call assert_equal(1484653763, strptime('%Y-%m-%d %X', '2017-01-17 11:49:23')) + + call assert_fails('call strptime()', 'E119:') + call assert_fails('call strptime("xxx")', 'E119:') + call assert_equal(0, strptime("%Y", '')) + call assert_equal(0, strptime("%Y", "xxx")) + + if exists('tz') + let $TZ = tz + else + unlet $TZ + endif +endfunc + func Test_resolve_unix() if !has('unix') return -- cgit From 93e9cf4b6c24945a7fda9e624b73cf8c315994e7 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 6 Dec 2020 11:02:06 -0500 Subject: vim-patch:8.1.2398: strptime() test fails on Japanese Mac Problem: strptime() test fails on Japanese Mac. Solution: Use %T instead of %X. https://github.com/vim/vim/commit/9a838fe543b69582b0773f7c38a57f16fb32d765 --- src/nvim/testdir/test_functions.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 5efd27d016..ea75aec52c 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -223,7 +223,7 @@ func Test_strptime() endif let $TZ = 'UTC' - call assert_equal(1484653763, strptime('%Y-%m-%d %X', '2017-01-17 11:49:23')) + call assert_equal(1484653763, strptime('%Y-%m-%d %T', '2017-01-17 11:49:23')) call assert_fails('call strptime()', 'E119:') call assert_fails('call strptime("xxx")', 'E119:') -- cgit From a7e0b0edbc2143b4efd6beda0498ef18789a2bdf Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 6 Dec 2020 11:05:22 -0500 Subject: vim-patch:8.2.0949: strptime() does not use DST MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Strptime() does not use DST. Solution: Set the tm_isdst field to -1. (Tomáš Janoušek, closes vim/vim#6230) https://github.com/vim/vim/commit/ea1233fccf4f52f2b4eaab3788a087878d1336fc --- src/nvim/testdir/test_functions.vim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index ea75aec52c..145da3070b 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -225,6 +225,10 @@ func Test_strptime() call assert_equal(1484653763, strptime('%Y-%m-%d %T', '2017-01-17 11:49:23')) + " Force DST and check that it's considered + let $TZ = 'WINTER0SUMMER,J1,J365' + call assert_equal(1484653763 - 3600, strptime('%Y-%m-%d %T', '2017-01-17 11:49:23')) + call assert_fails('call strptime()', 'E119:') call assert_fails('call strptime("xxx")', 'E119:') call assert_equal(0, strptime("%Y", '')) -- cgit From 423f3bc3e2d6aa8245a2cda1c4e7663387383ab7 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 27 Mar 2021 10:55:11 -0400 Subject: test/old: skip Test_strptime() on Windows POSIX strptime does not exist in Windows. There is a C++ workaround but I don't know how to use it. Julia ported BSD's "strptime()" but I can't compile the file or embed the relevant code into src/nvim/os/time.c I cannot use "#ifdef" in eval.lua because of function hashing. "#ifdef" is required to point "strptime()" to NULL such that "CheckFunction strptime" fails. --- src/nvim/testdir/test_functions.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 145da3070b..555f549743 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -217,6 +217,7 @@ endfunc func Test_strptime() CheckFunction strptime + CheckNotMSWindows if exists('$TZ') let tz = $TZ -- cgit