Skip to content

Commit 72338d5

Browse files
arihant2mathyouknowone
authored andcommitted
tzname on windows
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
1 parent 9856d94 commit 72338d5

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎vm/src/stdlib/time.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ mod decl {
4343
DateTime, Datelike, Timelike,
4444
};
4545
use std::time::Duration;
46+
#[cfg(target_env = "msvc")]
47+
#[cfg(not(target_arch = "wasm32"))]
48+
use windows::Win32::System::Time;
4649

4750
#[allow(dead_code)]
4851
pub(super) const SEC_TO_MS: i64 = 1000;
@@ -195,6 +198,18 @@ mod decl {
195198
unsafe { (to_str(super::c_tzname[0]), to_str(super::c_tzname[1])) }.into_pytuple(vm)
196199
}
197200

201+
#[cfg(target_env = "msvc")]
202+
#[cfg(not(target_arch = "wasm32"))]
203+
#[pyattr]
204+
fn tzname(vm: &VirtualMachine) -> crate::builtins::PyTupleRef {
205+
use crate::builtins::tuple::IntoPyTuple;
206+
let info = get_tz_info();
207+
let standard = widestring::decode_utf16_lossy(info.StandardName).filter(|&c| c != '\0').collect::<String>();
208+
let daylight = widestring::decode_utf16_lossy(info.DaylightName).filter(|&c| c != '\0').collect::<String>();
209+
let tz_name = (&*standard, &*daylight);
210+
tz_name.into_pytuple(vm)
211+
}
212+
198213
fn pyobj_to_date_time(
199214
value: Either<f64, i64>,
200215
vm: &VirtualMachine,

0 commit comments

Comments
 (0)