mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
time: Time.add (#7262)
This commit is contained in:
@@ -153,6 +153,21 @@ fn test_weekday_str() {
|
||||
}
|
||||
}
|
||||
|
||||
fn test_add() {
|
||||
d_seconds := 3
|
||||
d_microseconds := 13
|
||||
duration := time.Duration(d_seconds * time.second + d_microseconds * time.microsecond)
|
||||
t1 := time_to_test
|
||||
t2 := time_to_test.add(duration)
|
||||
assert t2.second == t1.second + d_seconds
|
||||
assert t2.microsecond == t1.microsecond + d_microseconds
|
||||
assert t2.unix == t1.unix + u64(d_seconds)
|
||||
t3 := time_to_test.add(-duration)
|
||||
assert t3.second == t1.second - d_seconds
|
||||
assert t3.microsecond == t1.microsecond - d_microseconds
|
||||
assert t3.unix == t1.unix - u64(d_seconds)
|
||||
}
|
||||
|
||||
fn test_add_days() {
|
||||
num_of_days := 3
|
||||
t := time_to_test.add_days(num_of_days)
|
||||
|
||||
Reference in New Issue
Block a user