Skip to content

Commit 9721646

Browse files
authored
foundation: remove optional chrono dependency (#666)
* foundation: remove optional chrono dependency * Bump version numbers for semver-incompatible changes
1 parent d7879eb commit 9721646

File tree

8 files changed

+18
-77
lines changed

8 files changed

+18
-77
lines changed

cocoa-foundation/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "cocoa-foundation"
44
description = "Bindings to Cocoa Foundation for macOS"
55
homepage = "https://github.com/servo/core-foundation-rs"
66
repository = "https://github.com/servo/core-foundation-rs"
7-
version = "0.1.2"
7+
version = "0.2.0"
88
authors = ["The Servo Project Developers"]
99
license = "MIT OR Apache-2.0"
1010
edition = "2018"
@@ -16,12 +16,11 @@ default-target = "x86_64-apple-darwin"
1616
block = "0.1"
1717
bitflags = "1.0"
1818
libc = "0.2"
19-
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
20-
core-graphics-types = { default-features = false, path = "../core-graphics-types", version = "0.1" }
19+
core-foundation = { default-features = false, path = "../core-foundation", version = "0.10" }
20+
core-graphics-types = { default-features = false, path = "../core-graphics-types", version = "0.2" }
2121
objc = "0.2.3"
2222

2323
[features]
2424
default = ["link"]
2525
# Disable to manually link. Enabled by default.
2626
link = ["core-foundation/link", "core-graphics-types/link"]
27-

cocoa/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "cocoa"
44
description = "Bindings to Cocoa for macOS"
55
homepage = "https://github.com/servo/core-foundation-rs"
66
repository = "https://github.com/servo/core-foundation-rs"
7-
version = "0.25.0"
7+
version = "0.26.0"
88
authors = ["The Servo Project Developers"]
99
license = "MIT OR Apache-2.0"
1010
edition = "2018"
@@ -16,9 +16,9 @@ default-target = "x86_64-apple-darwin"
1616
block = "0.1"
1717
bitflags = "1.0"
1818
libc = "0.2"
19-
cocoa-foundation = { default-features = false, path = "../cocoa-foundation", version = "0.1" }
20-
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
21-
core-graphics = { default-features = false, path = "../core-graphics", version = "0.23" }
19+
cocoa-foundation = { default-features = false, path = "../cocoa-foundation", version = "0.2" }
20+
core-foundation = { default-features = false, path = "../core-foundation", version = "0.10" }
21+
core-graphics = { default-features = false, path = "../core-graphics", version = "0.24" }
2222
foreign-types = "0.5"
2323
objc = "0.2.3"
2424

core-foundation/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "core-foundation"
33
description = "Bindings to Core Foundation for macOS"
44
homepage = "https://github.com/servo/core-foundation-rs"
55
repository = "https://github.com/servo/core-foundation-rs"
6-
version = "0.9.4"
6+
version = "0.10.0"
77
authors = ["The Servo Project Developers"]
88
license = "MIT OR Apache-2.0"
99
categories = ["os::macos-apis"]
@@ -17,15 +17,13 @@ version = "0.8.6"
1717

1818
[dependencies]
1919
libc = "0.2"
20-
chrono = { version = "0.4", optional = true }
2120
uuid = { version = "0.5", optional = true }
2221

2322
[features]
2423
default = ["link"]
2524

2625
mac_os_10_7_support = ["core-foundation-sys/mac_os_10_7_support"] # backwards compatibility
2726
mac_os_10_8_features = ["core-foundation-sys/mac_os_10_8_features"] # enables new features
28-
with-chrono = ["chrono"]
2927
with-uuid = ["uuid"]
3028
# Disable to manually link. Enabled by default.
3129
link = ["core-foundation-sys/link"]

core-foundation/src/date.rs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ pub use core_foundation_sys::date::*;
1414

1515
use crate::base::TCFType;
1616

17-
#[cfg(feature = "with-chrono")]
18-
use chrono::NaiveDateTime;
19-
2017
declare_TCFType! {
2118
/// A date.
2219
CFDate, CFDateRef
@@ -43,45 +40,13 @@ impl CFDate {
4340
pub fn abs_time(&self) -> CFAbsoluteTime {
4441
unsafe { CFDateGetAbsoluteTime(self.0) }
4542
}
46-
47-
#[cfg(feature = "with-chrono")]
48-
pub fn naive_utc(&self) -> NaiveDateTime {
49-
let ts = unsafe { self.abs_time() + kCFAbsoluteTimeIntervalSince1970 };
50-
let (secs, nanos) = if ts.is_sign_positive() {
51-
(ts.trunc() as i64, ts.fract())
52-
} else {
53-
// nanoseconds can't be negative in NaiveDateTime
54-
(ts.trunc() as i64 - 1, 1.0 - ts.fract().abs())
55-
};
56-
NaiveDateTime::from_timestamp(secs, (nanos * 1e9).floor() as u32)
57-
}
58-
59-
#[cfg(feature = "with-chrono")]
60-
pub fn from_naive_utc(time: NaiveDateTime) -> CFDate {
61-
let secs = time.timestamp();
62-
let nanos = time.timestamp_subsec_nanos();
63-
let ts = unsafe { secs as f64 + (nanos as f64 / 1e9) - kCFAbsoluteTimeIntervalSince1970 };
64-
CFDate::new(ts)
65-
}
6643
}
6744

6845
#[cfg(test)]
6946
mod test {
7047
use super::CFDate;
7148
use std::cmp::Ordering;
7249

73-
#[cfg(feature = "with-chrono")]
74-
use chrono::NaiveDateTime;
75-
76-
#[cfg(feature = "with-chrono")]
77-
fn approx_eq(a: f64, b: f64) -> bool {
78-
use std::f64;
79-
80-
let same_sign = a.is_sign_positive() == b.is_sign_positive();
81-
let equal = ((a - b).abs() / f64::min(a.abs() + b.abs(), f64::MAX)) < f64::EPSILON;
82-
same_sign && equal
83-
}
84-
8550
#[test]
8651
fn date_comparison() {
8752
let now = CFDate::now();
@@ -97,25 +62,4 @@ mod test {
9762
let same_time = CFDate::new(now.abs_time());
9863
assert_eq!(now, same_time);
9964
}
100-
101-
#[test]
102-
#[cfg(feature = "with-chrono")]
103-
fn date_chrono_conversion_positive() {
104-
let date = CFDate::now();
105-
let datetime = date.naive_utc();
106-
let converted = CFDate::from_naive_utc(datetime);
107-
assert!(approx_eq(date.abs_time(), converted.abs_time()));
108-
}
109-
110-
#[test]
111-
#[cfg(feature = "with-chrono")]
112-
fn date_chrono_conversion_negative() {
113-
use super::kCFAbsoluteTimeIntervalSince1970;
114-
115-
let ts = unsafe { kCFAbsoluteTimeIntervalSince1970 - 420.0 };
116-
let date = CFDate::new(ts);
117-
let datetime: NaiveDateTime = date.naive_utc();
118-
let converted = CFDate::from_naive_utc(datetime);
119-
assert!(approx_eq(date.abs_time(), converted.abs_time()));
120-
}
12165
}

core-graphics-types/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ name = "core-graphics-types"
33
description = "Bindings for some fundamental Core Graphics types"
44
homepage = "https://github.com/servo/core-foundation-rs"
55
repository = "https://github.com/servo/core-foundation-rs"
6-
version = "0.1.3"
6+
version = "0.2.0"
77
authors = ["The Servo Project Developers"]
88
license = "MIT OR Apache-2.0"
99
edition = "2018"
1010

1111
[dependencies]
1212
bitflags = "1.0"
13-
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9.4" }
13+
core-foundation = { default-features = false, path = "../core-foundation", version = "0.10" }
1414
libc = "0.2"
1515

1616
[features]

core-graphics/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "core-graphics"
33
description = "Bindings to Core Graphics for macOS"
44
homepage = "https://github.com/servo/core-foundation-rs"
55
repository = "https://github.com/servo/core-foundation-rs"
6-
version = "0.23.2"
6+
version = "0.24.0"
77
authors = ["The Servo Project Developers"]
88
license = "MIT OR Apache-2.0"
99
edition = "2018"
@@ -17,8 +17,8 @@ link = ["core-foundation/link", "core-graphics-types/link"]
1717

1818
[dependencies]
1919
bitflags = "1.0"
20-
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
21-
core-graphics-types = { default-features = false, path = "../core-graphics-types", version = "0.1" }
20+
core-foundation = { default-features = false, path = "../core-foundation", version = "0.10" }
21+
core-graphics-types = { default-features = false, path = "../core-graphics-types", version = "0.2" }
2222
foreign-types = "0.5.0"
2323
libc = "0.2"
2424

core-text/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "core-text"
3-
version = "20.1.0"
3+
version = "21.0.0"
44
authors = ["The Servo Project Developers"]
55
description = "Bindings to the Core Text framework."
66
license = "MIT OR Apache-2.0"
@@ -22,5 +22,5 @@ link = ["core-foundation/link", "core-graphics/link"]
2222
[dependencies]
2323
foreign-types = "0.5"
2424
libc = "0.2"
25-
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
26-
core-graphics = { default-features = false, path = "../core-graphics", version = "0.23.0" }
25+
core-foundation = { default-features = false, path = "../core-foundation", version = "0.10" }
26+
core-graphics = { default-features = false, path = "../core-graphics", version = "0.24" }

io-surface/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "io-surface"
33
description = "Bindings to IO Surface for macOS"
44
homepage = "https://github.com/servo/core-foundation-rs"
55
repository = "https://github.com/servo/core-foundation-rs"
6-
version = "0.15.1"
6+
version = "0.16.0"
77
authors = ["The Servo Project Developers"]
88
license = "MIT OR Apache-2.0"
99
edition = "2018"
@@ -13,7 +13,7 @@ default-target = "x86_64-apple-darwin"
1313

1414
[dependencies]
1515
libc = "0.2"
16-
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
16+
core-foundation = { default-features = false, path = "../core-foundation", version = "0.10" }
1717
core-foundation-sys = { default-features = false, path = "../core-foundation-sys", version = "0.8" }
1818
cgl = "0.3"
1919
leaky-cow = "0.1.1"

0 commit comments

Comments
 (0)