From f827477216e688ef59b68cada2d038124ec08185 Mon Sep 17 00:00:00 2001 From: Dave DeLong Date: Wed, 28 Feb 2024 22:45:51 -0700 Subject: [PATCH] Remove deprecations and convert warnings to issues --- README.md | 10 +++-- Sources/Time/1-Core Types/Instant.swift | 8 ++-- .../RegionalClock+CurrentValues.swift | 43 ------------------- Sources/Time/4-Fixed Values/Fixed.swift | 4 -- .../6-Adjustments/Fixed+SafeAdjustment.swift | 2 +- .../Time/Documentation.docc/ReleaseNotes.md | 14 ++++++ Sources/Time/Internals/Fixed+Internal.swift | 5 ++- 7 files changed, 29 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index b6e8fdd..b2de380 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Working with calendars can be extremely complicated and error-prone. **Time** so **Time** can be installed like any other Swift package. Add this to the `dependencies` section of your Package.swift: ```swift -.package(url: "https://github.com/davedelong/time", from: "0.9.5") +.package(url: "https://github.com/davedelong/time", from: "1.0.0") ``` ## Platform Support @@ -34,12 +34,16 @@ Here's the TL;DR of the documentation: - These values can be _formatted_ into human-readable strings via their `.format(...)` methods. -For additional information, refer to the documentation and included examples. +For additional information, refer to [the documentation][spi] and included examples. ## Contributing -**Time** is fully open source, available at [https://github.com/davedelong/time][ghi]. If you have feature requests, suggestions, or have discovered a bug, please open a [new issue][ghi]. +**Time** is fully open source, available at [https://github.com/davedelong/time][gh]. If you have feature requests, suggestions, or have discovered a bug, please open a [new issue][ghi]. [spi]: https://swiftpackageindex.com/davedelong/time [gh]: https://github.com/davedelong/time [ghi]: https://github.com/davedelong/time/issues + +## License + +**Time** is licensed under the MIT License. For more information, see the `LICENSE ` file. diff --git a/Sources/Time/1-Core Types/Instant.swift b/Sources/Time/1-Core Types/Instant.swift index 9512d44..e596997 100644 --- a/Sources/Time/1-Core Types/Instant.swift +++ b/Sources/Time/1-Core Types/Instant.swift @@ -4,22 +4,22 @@ import Foundation public struct Instant: Hashable, Comparable, InstantProtocol, Sendable { public typealias Duration = SISeconds - /// Determine if two Instants are equivalent. + /// Determine if two `Instant`s are equivalent. public static func ==(lhs: Instant, rhs: Instant) -> Bool { return lhs.intervalSinceReferenceEpoch == rhs.intervalSinceReferenceEpoch } - /// Determine if one Instant occurs before another Instant. + /// Determine if one `Instant` occurs before another `Instant`. public static func <(lhs: Instant, rhs: Instant) -> Bool { return lhs.intervalSinceReferenceEpoch < rhs.intervalSinceReferenceEpoch } - /// Determine the number of seconds between two Instants. + /// Determine the number of seconds between two `Instant`s. public static func -(lhs: Instant, rhs: Instant) -> SISeconds { return lhs.intervalSinceReferenceEpoch - rhs.intervalSinceReferenceEpoch } - /// Apply an offset in seconds to an Instant. + /// Apply an offset in seconds to an `Instant`. public static func +(lhs: Instant, rhs: SISeconds) -> Instant { return Instant(interval: lhs.intervalSinceEpoch + rhs, since: lhs.epoch) } diff --git a/Sources/Time/3-RegionalClock/RegionalClock+CurrentValues.swift b/Sources/Time/3-RegionalClock/RegionalClock+CurrentValues.swift index 86acd91..88b4735 100644 --- a/Sources/Time/3-RegionalClock/RegionalClock+CurrentValues.swift +++ b/Sources/Time/3-RegionalClock/RegionalClock+CurrentValues.swift @@ -79,46 +79,3 @@ extension RegionalClock { public var previousSecond: Fixed { return current().previous } } - -#warning("1.0: remove these deprecations") -extension RegionalClock { - - /// Retrieve the current `Fixed` calendrical value, accurate down to the specified unit. - @available(*, deprecated, renamed: "current") - public func this(_ unit: C.Type = C.self) -> Fixed { - return Fixed(region: region, instant: now) - } - - /// Retrieve the current calendar era of the `RegionalClock`. - @available(*, deprecated, renamed: "currentEra") - public var thisEra: Fixed { return current() } - - /// Retrieve the current calendar year of the `RegionalClock`. - @available(*, deprecated, renamed: "currentYear") - public var thisYear: Fixed { return current() } - - /// Retrieve the current calendar month of the `RegionalClock`. - @available(*, deprecated, renamed: "currentMonth") - public var thisMonth: Fixed { return current() } - - /// Retrieve the current calendar day of the `RegionalClock`. - @available(*, deprecated, renamed: "currentDay") - public var thisDay: Fixed { return current() } - - /// Retrieve the current calendar hour of the `RegionalClock`. - @available(*, deprecated, renamed: "currentHour") - public var thisHour: Fixed { return current() } - - /// Retrieve the current calendar minute of the `RegionalClock`. - @available(*, deprecated, renamed: "currentMinute") - public var thisMinute: Fixed { return current() } - - /// Retrieve the current calendar second of the `RegionalClock`. - @available(*, deprecated, renamed: "currentSecond") - public var thisSecond: Fixed { return current() } - - /// Retrieve the current calendar nanosecond of the `RegionalClock`. - @available(*, deprecated, renamed: "currentNanosecond") - public var thisNanosecond: Fixed { return current() } - -} diff --git a/Sources/Time/4-Fixed Values/Fixed.swift b/Sources/Time/4-Fixed Values/Fixed.swift index f6133a8..15087e2 100644 --- a/Sources/Time/4-Fixed Values/Fixed.swift +++ b/Sources/Time/4-Fixed Values/Fixed.swift @@ -21,10 +21,6 @@ import Foundation /// Fixed values are Equatable, Hashable, Comparable, Sendable, and Codable. public struct Fixed { - #warning("1.0: remove this deprecation") - @available(*, deprecated, message: "The `Smallest` generic parameter has been renamed", renamed: "Granularity") - public typealias Smallest = Granularity - /// The set of `Calendar.Components` represented by this particular `Fixed` value internal static var representedComponents: Set { return Calendar.Component.from(lower: Granularity.self, to: Era.self) diff --git a/Sources/Time/6-Adjustments/Fixed+SafeAdjustment.swift b/Sources/Time/6-Adjustments/Fixed+SafeAdjustment.swift index 449efb4..487131b 100644 --- a/Sources/Time/6-Adjustments/Fixed+SafeAdjustment.swift +++ b/Sources/Time/6-Adjustments/Fixed+SafeAdjustment.swift @@ -107,7 +107,7 @@ extension Fixed where Granularity: LTOEDay { var s = self let targetWeekday = region.calendar.firstWeekday - #warning("FUTURE: this is O(n). Could this be done in O(1) by pre-computing the number of days to move backwards?") + // Github issue #71 tracks improving this while s.dayOfWeek != targetWeekday { s = s.previousDay } diff --git a/Sources/Time/Documentation.docc/ReleaseNotes.md b/Sources/Time/Documentation.docc/ReleaseNotes.md index 4a9332a..2f98c53 100644 --- a/Sources/Time/Documentation.docc/ReleaseNotes.md +++ b/Sources/Time/Documentation.docc/ReleaseNotes.md @@ -2,3 +2,17 @@ A brief history of **Time**. +## 1.0.0 + +29 February, 2024 - The initial release of **Time**. + +In particular, thanks go to [Daniel Kennett][ikenndac], [Nathan Harris][mordil], [Reed Harston][rtharston], [Noah Blake][nononoah], and [Francis Chary][churowa] for their comments and suggestions on the 1.0 API and feature set, and especially for putting up with a constant stream of questions and requests for feedback. Additionally, a huge thanks to [Tim Vermeulen][timvermeulen] for helping formalize **Time**'s type safety via an astoundingly clever application of protocols. + +- [Github release](https://github.com/davedelong/time/releases/tag/1.0.0) + +[churowa]: https://github.com/churowa +[ikenndac]: https://github.com/ikenndac +[mordil]: https://github.com/mordil +[nononoah]: https://github.com/nononoah +[rtharston]: https://github.com/rtharston +[timvermeulen]: https://github.com/timvermeulen diff --git a/Sources/Time/Internals/Fixed+Internal.swift b/Sources/Time/Internals/Fixed+Internal.swift index e188113..70d5168 100644 --- a/Sources/Time/Internals/Fixed+Internal.swift +++ b/Sources/Time/Internals/Fixed+Internal.swift @@ -160,10 +160,11 @@ extension Fixed { NOTE: - this iteration is NOT typical iteration. For example if we're finding the nearest "13 minutes", then we'll iterate and check :00, :13, :26, :39, :52, :00, :13 ... etc + + ALSO: + - github issue #70 tracks improving the performance of this method */ - #warning("FUTURE: this could be optimized by using modulo arithmetic to try and 'jump' to the rounded values") - let represented = match.dateComponents.representedComponents guard let smallest = Calendar.Component.ascendingOrder.first(where: { represented.contains($0) }) else { // throw?