Mercurial > vim
comparison src/testdir/test_functions.vim @ 18669:9007e9896303 v8.1.2326
patch 8.1.2326: cannot parse a date/time string
Commit: https://github.com/vim/vim/commit/10455d43fef041309ce0613fa792c635dd71e3a8
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Nov 21 15:36:18 2019 +0100
patch 8.1.2326: cannot parse a date/time string
Problem: Cannot parse a date/time string.
Solution: Add strptime(). (Stephen Wall, closes #)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 21 Nov 2019 15:45:03 +0100 |
parents | 3089b422b9dc |
children | a9cfb0db187d |
comparison
equal
deleted
inserted
replaced
18668:ce55d198b1b5 | 18669:9007e9896303 |
---|---|
179 call assert_fails('call str2nr(1.2)', 'E806:') | 179 call assert_fails('call str2nr(1.2)', 'E806:') |
180 call assert_fails('call str2nr(10, [])', 'E474:') | 180 call assert_fails('call str2nr(10, [])', 'E474:') |
181 endfunc | 181 endfunc |
182 | 182 |
183 func Test_strftime() | 183 func Test_strftime() |
184 if !exists('*strftime') | 184 CheckFunction strftime |
185 return | 185 |
186 endif | |
187 " Format of strftime() depends on system. We assume | 186 " Format of strftime() depends on system. We assume |
188 " that basic formats tested here are available and | 187 " that basic formats tested here are available and |
189 " identical on all systems which support strftime(). | 188 " identical on all systems which support strftime(). |
190 " | 189 " |
191 " The 2nd parameter of strftime() is a local time, so the output day | 190 " The 2nd parameter of strftime() is a local time, so the output day |
220 if exists('tz') | 219 if exists('tz') |
221 let $TZ = tz | 220 let $TZ = tz |
222 else | 221 else |
223 unlet $TZ | 222 unlet $TZ |
224 endif | 223 endif |
225 | 224 endfunc |
225 | |
226 func Test_strptime() | |
227 CheckFunction strptime | |
228 | |
229 if exists('$TZ') | |
230 let tz = $TZ | |
231 endif | |
232 let $TZ = 'UTC' | |
233 | |
234 call assert_equal(1484653763, strptime('%Y-%m-%d %X', '2017-01-17 11:49:23')) | |
235 | |
236 call assert_fails('call strptime()', 'E119:') | |
237 call assert_fails('call strptime("xxx")', 'E119:') | |
238 call assert_equal(0, strptime("%Y", '')) | |
239 call assert_equal(0, strptime("%Y", "xxx")) | |
240 | |
241 if exists('tz') | |
242 let $TZ = tz | |
243 else | |
244 unlet $TZ | |
245 endif | |
226 endfunc | 246 endfunc |
227 | 247 |
228 func Test_resolve_unix() | 248 func Test_resolve_unix() |
229 if !has('unix') | 249 if !has('unix') |
230 return | 250 return |