v / vlib / time / parse.v
23 lines · 20 sloc · 605 bytes · c51d30bf5309653c6b573ec815268e69a78ea8cc
Raw
1// Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved.
2// Use of this source code is governed by an MIT license
3// that can be found in the LICENSE file.
4module time
5
6// TimeParseError represents a time parsing error.
7pub struct TimeParseError {
8 Error
9 code int
10 message string
11}
12
13// msg implements the `IError.msg()` method for `TimeParseError`.
14pub fn (err TimeParseError) msg() string {
15 return 'Invalid time format code: ${err.code}, error: ${err.message}'
16}
17
18fn error_invalid_time(code int, message string) IError {
19 return TimeParseError{
20 code: code
21 message: message
22 }
23}
24