mirror of
https://github.com/vlang/v.git
synced 2025-09-10 07:47:20 -04:00
time: add a tm_gmtoff field to C.tm
(a BSD and GNU extension) (#20907)
This commit is contained in:
parent
43fd568874
commit
8c9003fbd3
@ -17,6 +17,7 @@ pub struct C.tm {
|
||||
tm_wday int
|
||||
tm_yday int
|
||||
tm_isdst int
|
||||
tm_gmtoff int
|
||||
}
|
||||
|
||||
fn C.timegm(&C.tm) C.time_t
|
||||
|
@ -344,3 +344,16 @@ fn test_parse_three_letters_month() {
|
||||
tm_tm := time.parse_format(tm_s, format)!
|
||||
assert tm_tm.month == tm.month
|
||||
}
|
||||
|
||||
fn test_tm_gmtoff() {
|
||||
$if windows {
|
||||
return
|
||||
} $else {
|
||||
rawtime := i64(0) // C.time_t{}
|
||||
|
||||
C.time(&rawtime) // C.tm{}
|
||||
|
||||
info := C.localtime(&rawtime)
|
||||
assert info.tm_gmtoff == time.now().unix - time.utc().unix
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user