summaryrefslogtreecommitdiffstats
path: root/vendor/chrono/src/sys
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/chrono/src/sys
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/chrono/src/sys')
-rw-r--r--vendor/chrono/src/sys/stub.rs80
-rw-r--r--vendor/chrono/src/sys/unix.rs126
-rw-r--r--vendor/chrono/src/sys/windows.rs131
3 files changed, 0 insertions, 337 deletions
diff --git a/vendor/chrono/src/sys/stub.rs b/vendor/chrono/src/sys/stub.rs
deleted file mode 100644
index 9172a8522..000000000
--- a/vendor/chrono/src/sys/stub.rs
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use super::Tm;
-
-fn time_to_tm(ts: i64, tm: &mut Tm) {
- let leapyear = |year| -> bool { year % 4 == 0 && (year % 100 != 0 || year % 400 == 0) };
-
- static YTAB: [[i64; 12]; 2] = [
- [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
- [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
- ];
-
- let mut year = 1970;
-
- let dayclock = ts % 86400;
- let mut dayno = ts / 86400;
-
- tm.tm_sec = (dayclock % 60) as i32;
- tm.tm_min = ((dayclock % 3600) / 60) as i32;
- tm.tm_hour = (dayclock / 3600) as i32;
- tm.tm_wday = ((dayno + 4) % 7) as i32;
- loop {
- let yearsize = if leapyear(year) { 366 } else { 365 };
- if dayno >= yearsize {
- dayno -= yearsize;
- year += 1;
- } else {
- break;
- }
- }
- tm.tm_year = (year - 1900) as i32;
- tm.tm_yday = dayno as i32;
- let mut mon = 0;
- while dayno >= YTAB[if leapyear(year) { 1 } else { 0 }][mon] {
- dayno -= YTAB[if leapyear(year) { 1 } else { 0 }][mon];
- mon += 1;
- }
- tm.tm_mon = mon as i32;
- tm.tm_mday = dayno as i32 + 1;
- tm.tm_isdst = 0;
-}
-
-fn tm_to_time(tm: &Tm) -> i64 {
- let mut y = tm.tm_year as i64 + 1900;
- let mut m = tm.tm_mon as i64 + 1;
- if m <= 2 {
- y -= 1;
- m += 12;
- }
- let d = tm.tm_mday as i64;
- let h = tm.tm_hour as i64;
- let mi = tm.tm_min as i64;
- let s = tm.tm_sec as i64;
- (365 * y + y / 4 - y / 100 + y / 400 + 3 * (m + 1) / 5 + 30 * m + d - 719561) * 86400
- + 3600 * h
- + 60 * mi
- + s
-}
-
-pub fn time_to_local_tm(sec: i64, tm: &mut Tm) {
- // FIXME: Add timezone logic
- time_to_tm(sec, tm);
-}
-
-pub fn utc_tm_to_time(tm: &Tm) -> i64 {
- tm_to_time(tm)
-}
-
-pub fn local_tm_to_time(tm: &Tm) -> i64 {
- // FIXME: Add timezone logic
- tm_to_time(tm)
-}
diff --git a/vendor/chrono/src/sys/unix.rs b/vendor/chrono/src/sys/unix.rs
deleted file mode 100644
index 2f845e745..000000000
--- a/vendor/chrono/src/sys/unix.rs
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use super::Tm;
-use libc::{self, time_t};
-use std::io;
-use std::mem;
-
-#[cfg(any(target_os = "solaris", target_os = "illumos"))]
-extern "C" {
- static timezone: time_t;
- static altzone: time_t;
-}
-
-#[cfg(any(target_os = "solaris", target_os = "illumos"))]
-fn tzset() {
- extern "C" {
- fn tzset();
- }
- unsafe { tzset() }
-}
-
-fn rust_tm_to_tm(rust_tm: &Tm, tm: &mut libc::tm) {
- tm.tm_sec = rust_tm.tm_sec;
- tm.tm_min = rust_tm.tm_min;
- tm.tm_hour = rust_tm.tm_hour;
- tm.tm_mday = rust_tm.tm_mday;
- tm.tm_mon = rust_tm.tm_mon;
- tm.tm_year = rust_tm.tm_year;
- tm.tm_wday = rust_tm.tm_wday;
- tm.tm_yday = rust_tm.tm_yday;
- tm.tm_isdst = rust_tm.tm_isdst;
-}
-
-fn tm_to_rust_tm(tm: &libc::tm, utcoff: i32, rust_tm: &mut Tm) {
- rust_tm.tm_sec = tm.tm_sec;
- rust_tm.tm_min = tm.tm_min;
- rust_tm.tm_hour = tm.tm_hour;
- rust_tm.tm_mday = tm.tm_mday;
- rust_tm.tm_mon = tm.tm_mon;
- rust_tm.tm_year = tm.tm_year;
- rust_tm.tm_wday = tm.tm_wday;
- rust_tm.tm_yday = tm.tm_yday;
- rust_tm.tm_isdst = tm.tm_isdst;
- rust_tm.tm_utcoff = utcoff;
-}
-
-#[cfg(any(target_os = "nacl", target_os = "solaris", target_os = "illumos"))]
-unsafe fn timegm(tm: *mut libc::tm) -> time_t {
- use std::env::{remove_var, set_var, var_os};
- extern "C" {
- fn tzset();
- }
-
- let ret;
-
- let current_tz = var_os("TZ");
- set_var("TZ", "UTC");
- tzset();
-
- ret = libc::mktime(tm);
-
- if let Some(tz) = current_tz {
- set_var("TZ", tz);
- } else {
- remove_var("TZ");
- }
- tzset();
-
- ret
-}
-
-pub fn time_to_local_tm(sec: i64, tm: &mut Tm) {
- unsafe {
- let sec = sec as time_t;
- let mut out = mem::zeroed();
- if libc::localtime_r(&sec, &mut out).is_null() {
- panic!("localtime_r failed: {}", io::Error::last_os_error());
- }
- #[cfg(any(target_os = "solaris", target_os = "illumos"))]
- let gmtoff = {
- tzset();
- // < 0 means we don't know; assume we're not in DST.
- if out.tm_isdst == 0 {
- // timezone is seconds west of UTC, tm_gmtoff is seconds east
- -timezone
- } else if out.tm_isdst > 0 {
- -altzone
- } else {
- -timezone
- }
- };
- #[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
- let gmtoff = out.tm_gmtoff;
- tm_to_rust_tm(&out, gmtoff as i32, tm);
- }
-}
-
-pub fn utc_tm_to_time(rust_tm: &Tm) -> 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 = unsafe { mem::zeroed() };
- rust_tm_to_tm(rust_tm, &mut tm);
- unsafe { timegm(&mut tm) as i64 }
-}
-
-pub fn local_tm_to_time(rust_tm: &Tm) -> i64 {
- let mut tm = unsafe { mem::zeroed() };
- rust_tm_to_tm(rust_tm, &mut tm);
- unsafe { libc::mktime(&mut tm) as i64 }
-}
diff --git a/vendor/chrono/src/sys/windows.rs b/vendor/chrono/src/sys/windows.rs
deleted file mode 100644
index 3f90338e4..000000000
--- a/vendor/chrono/src/sys/windows.rs
+++ /dev/null
@@ -1,131 +0,0 @@
-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use super::Tm;
-use std::io;
-use std::mem;
-
-use winapi::shared::minwindef::*;
-use winapi::um::minwinbase::SYSTEMTIME;
-use winapi::um::timezoneapi::*;
-
-const HECTONANOSECS_IN_SEC: i64 = 10_000_000;
-const HECTONANOSEC_TO_UNIX_EPOCH: i64 = 11_644_473_600 * HECTONANOSECS_IN_SEC;
-
-fn time_to_file_time(sec: i64) -> FILETIME {
- let t = ((sec * HECTONANOSECS_IN_SEC) + HECTONANOSEC_TO_UNIX_EPOCH) as u64;
- FILETIME { dwLowDateTime: t as DWORD, dwHighDateTime: (t >> 32) as DWORD }
-}
-
-fn file_time_as_u64(ft: &FILETIME) -> u64 {
- ((ft.dwHighDateTime as u64) << 32) | (ft.dwLowDateTime as u64)
-}
-
-fn file_time_to_unix_seconds(ft: &FILETIME) -> i64 {
- let t = file_time_as_u64(ft) as i64;
- ((t - HECTONANOSEC_TO_UNIX_EPOCH) / HECTONANOSECS_IN_SEC) as i64
-}
-
-fn system_time_to_file_time(sys: &SYSTEMTIME) -> FILETIME {
- unsafe {
- let mut ft = mem::zeroed();
- SystemTimeToFileTime(sys, &mut ft);
- ft
- }
-}
-
-fn tm_to_system_time(tm: &Tm) -> SYSTEMTIME {
- let mut sys: SYSTEMTIME = unsafe { mem::zeroed() };
- sys.wSecond = tm.tm_sec as WORD;
- sys.wMinute = tm.tm_min as WORD;
- sys.wHour = tm.tm_hour as WORD;
- sys.wDay = tm.tm_mday as WORD;
- sys.wDayOfWeek = tm.tm_wday as WORD;
- sys.wMonth = (tm.tm_mon + 1) as WORD;
- sys.wYear = (tm.tm_year + 1900) as WORD;
- sys
-}
-
-fn system_time_to_tm(sys: &SYSTEMTIME, tm: &mut Tm) {
- tm.tm_sec = sys.wSecond as i32;
- tm.tm_min = sys.wMinute as i32;
- tm.tm_hour = sys.wHour as i32;
- tm.tm_mday = sys.wDay as i32;
- tm.tm_wday = sys.wDayOfWeek as i32;
- tm.tm_mon = (sys.wMonth - 1) as i32;
- tm.tm_year = (sys.wYear - 1900) as i32;
- tm.tm_yday = yday(tm.tm_year, tm.tm_mon + 1, tm.tm_mday);
-
- fn yday(year: i32, month: i32, day: i32) -> i32 {
- let leap = if month > 2 {
- if year % 4 == 0 {
- 1
- } else {
- 2
- }
- } else {
- 0
- };
- let july = if month > 7 { 1 } else { 0 };
-
- (month - 1) * 30 + month / 2 + (day - 1) - leap + july
- }
-}
-
-macro_rules! call {
- ($name:ident($($arg:expr),*)) => {
- if $name($($arg),*) == 0 {
- panic!(concat!(stringify!($name), " failed with: {}"),
- io::Error::last_os_error());
- }
- }
-}
-
-pub fn time_to_local_tm(sec: i64, tm: &mut Tm) {
- let ft = time_to_file_time(sec);
- unsafe {
- let mut utc = mem::zeroed();
- let mut local = mem::zeroed();
- call!(FileTimeToSystemTime(&ft, &mut utc));
- call!(SystemTimeToTzSpecificLocalTime(0 as *const _, &mut utc, &mut local));
- system_time_to_tm(&local, tm);
-
- let local = system_time_to_file_time(&local);
- let local_sec = file_time_to_unix_seconds(&local);
-
- let mut tz = mem::zeroed();
- GetTimeZoneInformation(&mut tz);
-
- // SystemTimeToTzSpecificLocalTime already applied the biases so
- // check if it non standard
- tm.tm_utcoff = (local_sec - sec) as i32;
- tm.tm_isdst = if tm.tm_utcoff == -60 * (tz.Bias + tz.StandardBias) { 0 } else { 1 };
- }
-}
-
-pub fn utc_tm_to_time(tm: &Tm) -> i64 {
- unsafe {
- let mut ft = mem::zeroed();
- let sys_time = tm_to_system_time(tm);
- call!(SystemTimeToFileTime(&sys_time, &mut ft));
- file_time_to_unix_seconds(&ft)
- }
-}
-
-pub fn local_tm_to_time(tm: &Tm) -> i64 {
- unsafe {
- let mut ft = mem::zeroed();
- let mut utc = mem::zeroed();
- let mut sys_time = tm_to_system_time(tm);
- call!(TzSpecificLocalTimeToSystemTime(0 as *mut _, &mut sys_time, &mut utc));
- call!(SystemTimeToFileTime(&utc, &mut ft));
- file_time_to_unix_seconds(&ft)
- }
-}