1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

string: make index() return ?int instead of int/-1

This commit is contained in:
Alexander Medvednikov
2019-11-30 13:09:05 +03:00
parent cc2bd0bb68
commit 81d4f66fbb
11 changed files with 117 additions and 103 deletions

View File

@@ -313,8 +313,7 @@ pub fn (t Time) clean12() string {
// `parse` parses time in the following format: "2018-01-27 12:48:34"
pub fn parse(s string) Time {
// println('parse="$s"')
pos := s.index(' ')
if pos <= 0 {
pos := s.index(' ') or {
println('bad time format')
return now()
}