mirror of
https://github.com/vlang/v.git
synced 2025-09-09 15:27:05 -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
@ -8,15 +8,16 @@ module time
|
||||
#include <errno.h>
|
||||
|
||||
pub struct C.tm {
|
||||
tm_sec int
|
||||
tm_min int
|
||||
tm_hour int
|
||||
tm_mday int
|
||||
tm_mon int
|
||||
tm_year int
|
||||
tm_wday int
|
||||
tm_yday int
|
||||
tm_isdst int
|
||||
tm_sec int
|
||||
tm_min int
|
||||
tm_hour int
|
||||
tm_mday int
|
||||
tm_mon int
|
||||
tm_year int
|
||||
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