Skip to content

Commit 36e8c5b

Browse files
committed
extend time.tzname, time.timezone, and time.daylight for windows
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
1 parent a46ce8e commit 36e8c5b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

vm/src/stdlib/time.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ extern "C" {
3030
fn c_tzset();
3131
}
3232

33+
#[cfg(target_env = "msvc")]
34+
#[cfg(not(target_arch = "wasm32"))]
35+
extern "C" {
36+
#[link_name = "__daylight"]
37+
static c_daylight: std::ffi::c_int;
38+
#[link_name = "__timezone"]
39+
static c_timezone: std::ffi::c_long;
40+
#[link_name = "__tzname"]
41+
static c_tzname: [*const std::ffi::c_char; 2];
42+
}
43+
3344
#[pymodule(name = "time", with(platform))]
3445
mod decl {
3546
use crate::{
@@ -157,22 +168,19 @@ mod decl {
157168
// unsafe { super::_tzset() };
158169
// }
159170

160-
#[cfg(not(target_env = "msvc"))]
161171
#[cfg(not(target_arch = "wasm32"))]
162172
#[pyattr]
163173
fn timezone(_vm: &VirtualMachine) -> std::ffi::c_long {
164174
unsafe { super::c_timezone }
165175
}
166176

167177
#[cfg(not(target_os = "freebsd"))]
168-
#[cfg(not(target_env = "msvc"))]
169178
#[cfg(not(target_arch = "wasm32"))]
170179
#[pyattr]
171180
fn daylight(_vm: &VirtualMachine) -> std::ffi::c_int {
172181
unsafe { super::c_daylight }
173182
}
174183

175-
#[cfg(not(target_env = "msvc"))]
176184
#[cfg(not(target_arch = "wasm32"))]
177185
#[pyattr]
178186
fn tzname(vm: &VirtualMachine) -> crate::builtins::PyTupleRef {

0 commit comments

Comments
 (0)