mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
time: - operator overloading (#7259)
This commit is contained in:
@@ -348,6 +348,13 @@ pub fn (t Time) str() string {
|
||||
return t.format_ss()
|
||||
}
|
||||
|
||||
// Time subtract using eperator overloading
|
||||
pub fn (lhs Time) -(rhs Time) Duration {
|
||||
lhs_micro := lhs.unix * 1000 * 1000 + u64(lhs.microsecond)
|
||||
rhs_micro := rhs.unix * 1000 * 1000 + u64(rhs.microsecond)
|
||||
return (i64(lhs_micro) - i64(rhs_micro)) * microsecond
|
||||
}
|
||||
|
||||
fn convert_ctime(t C.tm, microsecond int) Time {
|
||||
return Time{
|
||||
year: t.tm_year + 1900
|
||||
|
||||
Reference in New Issue
Block a user