mirror of
https://github.com/chronotope/chrono.git
synced 2025-10-02 23:36:17 +00:00
sys/unix: extract imports to global level
This commit is contained in:
parent
f78c833f02
commit
8f5c77728a
@ -11,6 +11,15 @@
|
|||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
use std::{io, ptr};
|
use std::{io, ptr};
|
||||||
|
|
||||||
|
#[cfg(not(any(
|
||||||
|
all(target_os = "android", target_pointer_width = "32"),
|
||||||
|
target_os = "nacl",
|
||||||
|
target_os = "solaris",
|
||||||
|
target_os = "illumos"
|
||||||
|
)))]
|
||||||
|
use libc::timegm;
|
||||||
|
#[cfg(all(target_os = "android", target_pointer_width = "32"))]
|
||||||
|
use libc::timegm64 as timegm;
|
||||||
use libc::{self, time_t};
|
use libc::{self, time_t};
|
||||||
|
|
||||||
use super::{DateTime, FixedOffset, Local, NaiveDate, NaiveDateTime, NaiveTime};
|
use super::{DateTime, FixedOffset, Local, NaiveDate, NaiveDateTime, NaiveTime};
|
||||||
@ -129,16 +138,6 @@ unsafe fn timegm(tm: *mut libc::tm) -> time_t {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn utc_naive_to_unix(d: &NaiveDateTime) -> i64 {
|
fn utc_naive_to_unix(d: &NaiveDateTime) -> i64 {
|
||||||
#[cfg(not(any(
|
|
||||||
all(target_os = "android", target_pointer_width = "32"),
|
|
||||||
target_os = "nacl",
|
|
||||||
target_os = "solaris",
|
|
||||||
target_os = "illumos"
|
|
||||||
)))]
|
|
||||||
use libc::timegm;
|
|
||||||
#[cfg(all(target_os = "android", target_pointer_width = "32"))]
|
|
||||||
use libc::timegm64 as timegm;
|
|
||||||
|
|
||||||
let mut tm = naive_to_tm(d);
|
let mut tm = naive_to_tm(d);
|
||||||
unsafe { timegm(&mut tm) as i64 }
|
unsafe { timegm(&mut tm) as i64 }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user