foundation: remove optional chrono dependency (#666)
* foundation: remove optional chrono dependency * Bump version numbers for semver-incompatible changes
This commit is contained in:
@@ -4,7 +4,7 @@ name = "cocoa-foundation"
|
|||||||
description = "Bindings to Cocoa Foundation for macOS"
|
description = "Bindings to Cocoa Foundation for macOS"
|
||||||
homepage = "https://github.com/servo/core-foundation-rs"
|
homepage = "https://github.com/servo/core-foundation-rs"
|
||||||
repository = "https://github.com/servo/core-foundation-rs"
|
repository = "https://github.com/servo/core-foundation-rs"
|
||||||
version = "0.1.2"
|
version = "0.2.0"
|
||||||
authors = ["The Servo Project Developers"]
|
authors = ["The Servo Project Developers"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@@ -16,12 +16,11 @@ default-target = "x86_64-apple-darwin"
|
|||||||
block = "0.1"
|
block = "0.1"
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
|
core-foundation = { default-features = false, path = "../core-foundation", version = "0.10" }
|
||||||
core-graphics-types = { default-features = false, path = "../core-graphics-types", version = "0.1" }
|
core-graphics-types = { default-features = false, path = "../core-graphics-types", version = "0.2" }
|
||||||
objc = "0.2.3"
|
objc = "0.2.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["link"]
|
default = ["link"]
|
||||||
# Disable to manually link. Enabled by default.
|
# Disable to manually link. Enabled by default.
|
||||||
link = ["core-foundation/link", "core-graphics-types/link"]
|
link = ["core-foundation/link", "core-graphics-types/link"]
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -4,7 +4,7 @@ name = "cocoa"
|
|||||||
description = "Bindings to Cocoa for macOS"
|
description = "Bindings to Cocoa for macOS"
|
||||||
homepage = "https://github.com/servo/core-foundation-rs"
|
homepage = "https://github.com/servo/core-foundation-rs"
|
||||||
repository = "https://github.com/servo/core-foundation-rs"
|
repository = "https://github.com/servo/core-foundation-rs"
|
||||||
version = "0.25.0"
|
version = "0.26.0"
|
||||||
authors = ["The Servo Project Developers"]
|
authors = ["The Servo Project Developers"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@@ -16,9 +16,9 @@ default-target = "x86_64-apple-darwin"
|
|||||||
block = "0.1"
|
block = "0.1"
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
cocoa-foundation = { default-features = false, path = "../cocoa-foundation", version = "0.1" }
|
cocoa-foundation = { default-features = false, path = "../cocoa-foundation", version = "0.2" }
|
||||||
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
|
core-foundation = { default-features = false, path = "../core-foundation", version = "0.10" }
|
||||||
core-graphics = { default-features = false, path = "../core-graphics", version = "0.23" }
|
core-graphics = { default-features = false, path = "../core-graphics", version = "0.24" }
|
||||||
foreign-types = "0.5"
|
foreign-types = "0.5"
|
||||||
objc = "0.2.3"
|
objc = "0.2.3"
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name = "core-foundation"
|
|||||||
description = "Bindings to Core Foundation for macOS"
|
description = "Bindings to Core Foundation for macOS"
|
||||||
homepage = "https://github.com/servo/core-foundation-rs"
|
homepage = "https://github.com/servo/core-foundation-rs"
|
||||||
repository = "https://github.com/servo/core-foundation-rs"
|
repository = "https://github.com/servo/core-foundation-rs"
|
||||||
version = "0.9.4"
|
version = "0.10.0"
|
||||||
authors = ["The Servo Project Developers"]
|
authors = ["The Servo Project Developers"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
categories = ["os::macos-apis"]
|
categories = ["os::macos-apis"]
|
||||||
@@ -17,7 +17,6 @@ version = "0.8.6"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
chrono = { version = "0.4", optional = true }
|
|
||||||
uuid = { version = "0.5", optional = true }
|
uuid = { version = "0.5", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
@@ -25,7 +24,6 @@ default = ["link"]
|
|||||||
|
|
||||||
mac_os_10_7_support = ["core-foundation-sys/mac_os_10_7_support"] # backwards compatibility
|
mac_os_10_7_support = ["core-foundation-sys/mac_os_10_7_support"] # backwards compatibility
|
||||||
mac_os_10_8_features = ["core-foundation-sys/mac_os_10_8_features"] # enables new features
|
mac_os_10_8_features = ["core-foundation-sys/mac_os_10_8_features"] # enables new features
|
||||||
with-chrono = ["chrono"]
|
|
||||||
with-uuid = ["uuid"]
|
with-uuid = ["uuid"]
|
||||||
# Disable to manually link. Enabled by default.
|
# Disable to manually link. Enabled by default.
|
||||||
link = ["core-foundation-sys/link"]
|
link = ["core-foundation-sys/link"]
|
||||||
|
|||||||
@@ -14,9 +14,6 @@ pub use core_foundation_sys::date::*;
|
|||||||
|
|
||||||
use crate::base::TCFType;
|
use crate::base::TCFType;
|
||||||
|
|
||||||
#[cfg(feature = "with-chrono")]
|
|
||||||
use chrono::NaiveDateTime;
|
|
||||||
|
|
||||||
declare_TCFType! {
|
declare_TCFType! {
|
||||||
/// A date.
|
/// A date.
|
||||||
CFDate, CFDateRef
|
CFDate, CFDateRef
|
||||||
@@ -43,26 +40,6 @@ impl CFDate {
|
|||||||
pub fn abs_time(&self) -> CFAbsoluteTime {
|
pub fn abs_time(&self) -> CFAbsoluteTime {
|
||||||
unsafe { CFDateGetAbsoluteTime(self.0) }
|
unsafe { CFDateGetAbsoluteTime(self.0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "with-chrono")]
|
|
||||||
pub fn naive_utc(&self) -> NaiveDateTime {
|
|
||||||
let ts = unsafe { self.abs_time() + kCFAbsoluteTimeIntervalSince1970 };
|
|
||||||
let (secs, nanos) = if ts.is_sign_positive() {
|
|
||||||
(ts.trunc() as i64, ts.fract())
|
|
||||||
} else {
|
|
||||||
// nanoseconds can't be negative in NaiveDateTime
|
|
||||||
(ts.trunc() as i64 - 1, 1.0 - ts.fract().abs())
|
|
||||||
};
|
|
||||||
NaiveDateTime::from_timestamp(secs, (nanos * 1e9).floor() as u32)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "with-chrono")]
|
|
||||||
pub fn from_naive_utc(time: NaiveDateTime) -> CFDate {
|
|
||||||
let secs = time.timestamp();
|
|
||||||
let nanos = time.timestamp_subsec_nanos();
|
|
||||||
let ts = unsafe { secs as f64 + (nanos as f64 / 1e9) - kCFAbsoluteTimeIntervalSince1970 };
|
|
||||||
CFDate::new(ts)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -70,18 +47,6 @@ mod test {
|
|||||||
use super::CFDate;
|
use super::CFDate;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
#[cfg(feature = "with-chrono")]
|
|
||||||
use chrono::NaiveDateTime;
|
|
||||||
|
|
||||||
#[cfg(feature = "with-chrono")]
|
|
||||||
fn approx_eq(a: f64, b: f64) -> bool {
|
|
||||||
use std::f64;
|
|
||||||
|
|
||||||
let same_sign = a.is_sign_positive() == b.is_sign_positive();
|
|
||||||
let equal = ((a - b).abs() / f64::min(a.abs() + b.abs(), f64::MAX)) < f64::EPSILON;
|
|
||||||
same_sign && equal
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn date_comparison() {
|
fn date_comparison() {
|
||||||
let now = CFDate::now();
|
let now = CFDate::now();
|
||||||
@@ -97,25 +62,4 @@ mod test {
|
|||||||
let same_time = CFDate::new(now.abs_time());
|
let same_time = CFDate::new(now.abs_time());
|
||||||
assert_eq!(now, same_time);
|
assert_eq!(now, same_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[cfg(feature = "with-chrono")]
|
|
||||||
fn date_chrono_conversion_positive() {
|
|
||||||
let date = CFDate::now();
|
|
||||||
let datetime = date.naive_utc();
|
|
||||||
let converted = CFDate::from_naive_utc(datetime);
|
|
||||||
assert!(approx_eq(date.abs_time(), converted.abs_time()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[cfg(feature = "with-chrono")]
|
|
||||||
fn date_chrono_conversion_negative() {
|
|
||||||
use super::kCFAbsoluteTimeIntervalSince1970;
|
|
||||||
|
|
||||||
let ts = unsafe { kCFAbsoluteTimeIntervalSince1970 - 420.0 };
|
|
||||||
let date = CFDate::new(ts);
|
|
||||||
let datetime: NaiveDateTime = date.naive_utc();
|
|
||||||
let converted = CFDate::from_naive_utc(datetime);
|
|
||||||
assert!(approx_eq(date.abs_time(), converted.abs_time()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ name = "core-graphics-types"
|
|||||||
description = "Bindings for some fundamental Core Graphics types"
|
description = "Bindings for some fundamental Core Graphics types"
|
||||||
homepage = "https://github.com/servo/core-foundation-rs"
|
homepage = "https://github.com/servo/core-foundation-rs"
|
||||||
repository = "https://github.com/servo/core-foundation-rs"
|
repository = "https://github.com/servo/core-foundation-rs"
|
||||||
version = "0.1.3"
|
version = "0.2.0"
|
||||||
authors = ["The Servo Project Developers"]
|
authors = ["The Servo Project Developers"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9.4" }
|
core-foundation = { default-features = false, path = "../core-foundation", version = "0.10" }
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name = "core-graphics"
|
|||||||
description = "Bindings to Core Graphics for macOS"
|
description = "Bindings to Core Graphics for macOS"
|
||||||
homepage = "https://github.com/servo/core-foundation-rs"
|
homepage = "https://github.com/servo/core-foundation-rs"
|
||||||
repository = "https://github.com/servo/core-foundation-rs"
|
repository = "https://github.com/servo/core-foundation-rs"
|
||||||
version = "0.23.2"
|
version = "0.24.0"
|
||||||
authors = ["The Servo Project Developers"]
|
authors = ["The Servo Project Developers"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@@ -17,8 +17,8 @@ link = ["core-foundation/link", "core-graphics-types/link"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
|
core-foundation = { default-features = false, path = "../core-foundation", version = "0.10" }
|
||||||
core-graphics-types = { default-features = false, path = "../core-graphics-types", version = "0.1" }
|
core-graphics-types = { default-features = false, path = "../core-graphics-types", version = "0.2" }
|
||||||
foreign-types = "0.5.0"
|
foreign-types = "0.5.0"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "core-text"
|
name = "core-text"
|
||||||
version = "20.1.0"
|
version = "21.0.0"
|
||||||
authors = ["The Servo Project Developers"]
|
authors = ["The Servo Project Developers"]
|
||||||
description = "Bindings to the Core Text framework."
|
description = "Bindings to the Core Text framework."
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
@@ -22,5 +22,5 @@ link = ["core-foundation/link", "core-graphics/link"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
foreign-types = "0.5"
|
foreign-types = "0.5"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
|
core-foundation = { default-features = false, path = "../core-foundation", version = "0.10" }
|
||||||
core-graphics = { default-features = false, path = "../core-graphics", version = "0.23.0" }
|
core-graphics = { default-features = false, path = "../core-graphics", version = "0.24" }
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name = "io-surface"
|
|||||||
description = "Bindings to IO Surface for macOS"
|
description = "Bindings to IO Surface for macOS"
|
||||||
homepage = "https://github.com/servo/core-foundation-rs"
|
homepage = "https://github.com/servo/core-foundation-rs"
|
||||||
repository = "https://github.com/servo/core-foundation-rs"
|
repository = "https://github.com/servo/core-foundation-rs"
|
||||||
version = "0.15.1"
|
version = "0.16.0"
|
||||||
authors = ["The Servo Project Developers"]
|
authors = ["The Servo Project Developers"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@@ -13,7 +13,7 @@ default-target = "x86_64-apple-darwin"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
|
core-foundation = { default-features = false, path = "../core-foundation", version = "0.10" }
|
||||||
core-foundation-sys = { default-features = false, path = "../core-foundation-sys", version = "0.8" }
|
core-foundation-sys = { default-features = false, path = "../core-foundation-sys", version = "0.8" }
|
||||||
cgl = "0.3"
|
cgl = "0.3"
|
||||||
leaky-cow = "0.1.1"
|
leaky-cow = "0.1.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user