Mercurial > vim
comparison runtime/doc/eval.txt @ 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 | cb3163d590a1 |
children | 1febd1aa9930 |
comparison
equal
deleted
inserted
replaced
18668:ce55d198b1b5 | 18669:9007e9896303 |
---|---|
1 *eval.txt* For Vim version 8.1. Last change: 2019 Nov 17 | 1 *eval.txt* For Vim version 8.1. Last change: 2019 Nov 21 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
486 as a key. | 486 as a key. |
487 *literal-Dict* *#{}* | 487 *literal-Dict* *#{}* |
488 To avoid having to put quotes around every key the #{} form can be used. This | 488 To avoid having to put quotes around every key the #{} form can be used. This |
489 does require the key to consist only of ASCII letters, digits, '-' and '_'. | 489 does require the key to consist only of ASCII letters, digits, '-' and '_'. |
490 Example: > | 490 Example: > |
491 let mydict = #{zero: 0, one_key: 1, two-key: 2, 333: 3} | 491 :let mydict = #{zero: 0, one_key: 1, two-key: 2, 333: 3} |
492 Note that 333 here is the string "333". Empty keys are not possible with #{}. | 492 Note that 333 here is the string "333". Empty keys are not possible with #{}. |
493 | 493 |
494 A value can be any expression. Using a Dictionary for a value creates a | 494 A value can be any expression. Using a Dictionary for a value creates a |
495 nested Dictionary: > | 495 nested Dictionary: > |
496 :let nestdict = {1: {11: 'a', 12: 'b'}, 2: {21: 'c'}} | 496 :let nestdict = {1: {11: 'a', 12: 'b'}, 2: {21: 'c'}} |
2665 remote_read({serverid} [, {timeout}]) | 2665 remote_read({serverid} [, {timeout}]) |
2666 String read reply string | 2666 String read reply string |
2667 remote_send({server}, {string} [, {idvar}]) | 2667 remote_send({server}, {string} [, {idvar}]) |
2668 String send key sequence | 2668 String send key sequence |
2669 remote_startserver({name}) none become server {name} | 2669 remote_startserver({name}) none become server {name} |
2670 remove({list}, {idx} [, {end}]) any/List | 2670 remove({list}, {idx} [, {end}]) any/List |
2671 remove items {idx}-{end} from {list} | 2671 remove items {idx}-{end} from {list} |
2672 remove({blob}, {idx} [, {end}]) Number/Blob | 2672 remove({blob}, {idx} [, {end}]) Number/Blob |
2673 remove bytes {idx}-{end} from {blob} | 2673 remove bytes {idx}-{end} from {blob} |
2674 remove({dict}, {key}) any remove entry {key} from {dict} | 2674 remove({dict}, {key}) any remove entry {key} from {dict} |
2675 rename({from}, {to}) Number rename (move) file from {from} to {to} | 2675 rename({from}, {to}) Number rename (move) file from {from} to {to} |
2768 Number convert String to Number | 2768 Number convert String to Number |
2769 strchars({expr} [, {skipcc}]) Number character length of the String {expr} | 2769 strchars({expr} [, {skipcc}]) Number character length of the String {expr} |
2770 strcharpart({str}, {start} [, {len}]) | 2770 strcharpart({str}, {start} [, {len}]) |
2771 String {len} characters of {str} at {start} | 2771 String {len} characters of {str} at {start} |
2772 strdisplaywidth({expr} [, {col}]) Number display length of the String {expr} | 2772 strdisplaywidth({expr} [, {col}]) Number display length of the String {expr} |
2773 strftime({format} [, {time}]) String time in specified format | 2773 strftime({format} [, {time}]) String format time with a specified format |
2774 strgetchar({str}, {index}) Number get char {index} from {str} | 2774 strgetchar({str}, {index}) Number get char {index} from {str} |
2775 stridx({haystack}, {needle} [, {start}]) | 2775 stridx({haystack}, {needle} [, {start}]) |
2776 Number index of {needle} in {haystack} | 2776 Number index of {needle} in {haystack} |
2777 string({expr}) String String representation of {expr} value | 2777 string({expr}) String String representation of {expr} value |
2778 strlen({expr}) Number length of the String {expr} | 2778 strlen({expr}) Number length of the String {expr} |
2779 strpart({str}, {start} [, {len}]) | 2779 strpart({str}, {start} [, {len}]) |
2780 String {len} characters of {str} at {start} | 2780 String {len} characters of {str} at {start} |
2781 strptime({format}, {timestring}) | |
2782 Number Convert {timestring} to unix timestamp | |
2781 strridx({haystack}, {needle} [, {start}]) | 2783 strridx({haystack}, {needle} [, {start}]) |
2782 Number last index of {needle} in {haystack} | 2784 Number last index of {needle} in {haystack} |
2783 strtrans({expr}) String translate string to make it printable | 2785 strtrans({expr}) String translate string to make it printable |
2784 strwidth({expr}) Number display cell length of the String {expr} | 2786 strwidth({expr}) Number display cell length of the String {expr} |
2785 submatch({nr} [, {list}]) String or List | 2787 submatch({nr} [, {list}]) String or List |
5632 quickfix 1 if quickfix or location list window | 5634 quickfix 1 if quickfix or location list window |
5633 {only with the +quickfix feature} | 5635 {only with the +quickfix feature} |
5634 terminal 1 if a terminal window | 5636 terminal 1 if a terminal window |
5635 {only with the +terminal feature} | 5637 {only with the +terminal feature} |
5636 tabnr tab page number | 5638 tabnr tab page number |
5637 topline first displayed buffer line | 5639 topline first displayed buffer line |
5638 variables a reference to the dictionary with | 5640 variables a reference to the dictionary with |
5639 window-local variables | 5641 window-local variables |
5640 width window width | 5642 width window width |
5641 winbar 1 if the window has a toolbar, 0 | 5643 winbar 1 if the window has a toolbar, 0 |
5642 otherwise | 5644 otherwise |
5650 Can also be used as a |method|: > | 5652 Can also be used as a |method|: > |
5651 GetWinnr()->getwininfo() | 5653 GetWinnr()->getwininfo() |
5652 | 5654 |
5653 getwinpos([{timeout}]) *getwinpos()* | 5655 getwinpos([{timeout}]) *getwinpos()* |
5654 The result is a list with two numbers, the result of | 5656 The result is a list with two numbers, the result of |
5655 getwinposx() and getwinposy() combined: | 5657 |getwinposx()| and |getwinposy()| combined: |
5656 [x-pos, y-pos] | 5658 [x-pos, y-pos] |
5657 {timeout} can be used to specify how long to wait in msec for | 5659 {timeout} can be used to specify how long to wait in msec for |
5658 a response from the terminal. When omitted 100 msec is used. | 5660 a response from the terminal. When omitted 100 msec is used. |
5659 Use a longer time for a remote terminal. | 5661 Use a longer time for a remote terminal. |
5660 When using a value less than 10 and no response is received | 5662 When using a value less than 10 and no response is received |
6612 Can also be used as a |method|: > | 6614 Can also be used as a |method|: > |
6613 GetListenerId()->listener_remove() | 6615 GetListenerId()->listener_remove() |
6614 | 6616 |
6615 localtime() *localtime()* | 6617 localtime() *localtime()* |
6616 Return the current time, measured as seconds since 1st Jan | 6618 Return the current time, measured as seconds since 1st Jan |
6617 1970. See also |strftime()| and |getftime()|. | 6619 1970. See also |strftime()|, |strptime()| and |getftime()|. |
6618 | 6620 |
6619 | 6621 |
6620 log({expr}) *log()* | 6622 log({expr}) *log()* |
6621 Return the natural logarithm (base e) of {expr} as a |Float|. | 6623 Return the natural logarithm (base e) of {expr} as a |Float|. |
6622 {expr} must evaluate to a |Float| or a |Number| in the range | 6624 {expr} must evaluate to a |Float| or a |Number| in the range |
7101 | 7103 |
7102 < This function is not available in the |sandbox|. | 7104 < This function is not available in the |sandbox|. |
7103 | 7105 |
7104 There is no error if the directory already exists and the "p" | 7106 There is no error if the directory already exists and the "p" |
7105 flag is passed (since patch 8.0.1708). However, without the | 7107 flag is passed (since patch 8.0.1708). However, without the |
7106 "p" option the call will fail. | 7108 "p" option the call will fail. |
7107 | 7109 |
7108 The function result is a Number, which is 1 if the call was | 7110 The function result is a Number, which is 1 if the call was |
7109 successful or 0 if the directory creation failed or partly | 7111 successful or 0 if the directory creation failed or partly |
7110 failed. | 7112 failed. |
7111 | 7113 |
7112 Not available on all systems. To check use: > | 7114 Not available on all systems. To check use: > |
7113 :if exists("*mkdir") | 7115 :if exists("*mkdir") |
9265 specified by the {format} string. The given {time} is used, | 9267 specified by the {format} string. The given {time} is used, |
9266 or the current time if no time is given. The accepted | 9268 or the current time if no time is given. The accepted |
9267 {format} depends on your system, thus this is not portable! | 9269 {format} depends on your system, thus this is not portable! |
9268 See the manual page of the C function strftime() for the | 9270 See the manual page of the C function strftime() for the |
9269 format. The maximum length of the result is 80 characters. | 9271 format. The maximum length of the result is 80 characters. |
9270 See also |localtime()| and |getftime()|. | 9272 See also |localtime()|, |getftime()| and |strptime()|. |
9271 The language can be changed with the |:language| command. | 9273 The language can be changed with the |:language| command. |
9272 Examples: > | 9274 Examples: > |
9273 :echo strftime("%c") Sun Apr 27 11:49:23 1997 | 9275 :echo strftime("%c") Sun Apr 27 11:49:23 1997 |
9274 :echo strftime("%Y %b %d %X") 1997 Apr 27 11:53:25 | 9276 :echo strftime("%Y %b %d %X") 1997 Apr 27 11:53:25 |
9275 :echo strftime("%y%m%d %T") 970427 11:53:55 | 9277 :echo strftime("%y%m%d %T") 970427 11:53:55 |
9365 example, to get three bytes under and after the cursor: > | 9367 example, to get three bytes under and after the cursor: > |
9366 strpart(getline("."), col(".") - 1, 3) | 9368 strpart(getline("."), col(".") - 1, 3) |
9367 < | 9369 < |
9368 Can also be used as a |method|: > | 9370 Can also be used as a |method|: > |
9369 GetText()->strpart(5) | 9371 GetText()->strpart(5) |
9372 | |
9373 strptime({format}, {timestring}) *strptime()* | |
9374 The result is a Number, which is a unix timestamp representing | |
9375 the date and time in {timestring}, which is expected to match | |
9376 the format specified in {format}. | |
9377 | |
9378 The accepted {format} depends on your system, thus this is not | |
9379 portable! See the manual page of the C function strptime() | |
9380 for the format. Especially avoid "%c". The value of $TZ also | |
9381 matters. | |
9382 | |
9383 If the {timestring} cannot be parsed with {format} zero is | |
9384 returned. If you do not know the format of {timestring} you | |
9385 can try different {format} values until you get a non-zero | |
9386 result. | |
9387 | |
9388 See also |strftime()|. | |
9389 Examples: > | |
9390 :echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23") | |
9391 < 862156163 > | |
9392 :echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55")) | |
9393 < Sun Apr 27 11:53:55 1997 > | |
9394 :echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600) | |
9395 < Sun Apr 27 12:53:55 1997 | |
9396 | |
9397 Not available on all systems. To check use: > | |
9398 :if exists("*strptime") | |
9399 | |
9370 | 9400 |
9371 strridx({haystack}, {needle} [, {start}]) *strridx()* | 9401 strridx({haystack}, {needle} [, {start}]) *strridx()* |
9372 The result is a Number, which gives the byte index in | 9402 The result is a Number, which gives the byte index in |
9373 {haystack} of the last occurrence of the String {needle}. | 9403 {haystack} of the last occurrence of the String {needle}. |
9374 When {start} is specified, matches beyond this index are | 9404 When {start} is specified, matches beyond this index are |