Skip to content

Commit

Permalink
Remove deprecations and convert warnings to issues
Browse files Browse the repository at this point in the history
  • Loading branch information
davedelong committed Feb 29, 2024
1 parent 3d65578 commit f827477
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 57 deletions.
10 changes: 7 additions & 3 deletions README.md
Expand Up @@ -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
Expand All @@ -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.
8 changes: 4 additions & 4 deletions Sources/Time/1-Core Types/Instant.swift
Expand Up @@ -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)
}
Expand Down
43 changes: 0 additions & 43 deletions Sources/Time/3-RegionalClock/RegionalClock+CurrentValues.swift
Expand Up @@ -79,46 +79,3 @@ extension RegionalClock {
public var previousSecond: Fixed<Second> { 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<C: Unit>(_ unit: C.Type = C.self) -> Fixed<C> {
return Fixed(region: region, instant: now)
}

/// Retrieve the current calendar era of the `RegionalClock`.
@available(*, deprecated, renamed: "currentEra")
public var thisEra: Fixed<Era> { return current() }

/// Retrieve the current calendar year of the `RegionalClock`.
@available(*, deprecated, renamed: "currentYear")
public var thisYear: Fixed<Year> { return current() }

/// Retrieve the current calendar month of the `RegionalClock`.
@available(*, deprecated, renamed: "currentMonth")
public var thisMonth: Fixed<Month> { return current() }

/// Retrieve the current calendar day of the `RegionalClock`.
@available(*, deprecated, renamed: "currentDay")
public var thisDay: Fixed<Day> { return current() }

/// Retrieve the current calendar hour of the `RegionalClock`.
@available(*, deprecated, renamed: "currentHour")
public var thisHour: Fixed<Hour> { return current() }

/// Retrieve the current calendar minute of the `RegionalClock`.
@available(*, deprecated, renamed: "currentMinute")
public var thisMinute: Fixed<Minute> { return current() }

/// Retrieve the current calendar second of the `RegionalClock`.
@available(*, deprecated, renamed: "currentSecond")
public var thisSecond: Fixed<Second> { return current() }

/// Retrieve the current calendar nanosecond of the `RegionalClock`.
@available(*, deprecated, renamed: "currentNanosecond")
public var thisNanosecond: Fixed<Nanosecond> { return current() }

}
4 changes: 0 additions & 4 deletions Sources/Time/4-Fixed Values/Fixed.swift
Expand Up @@ -21,10 +21,6 @@ import Foundation
/// Fixed values are Equatable, Hashable, Comparable, Sendable, and Codable.
public struct Fixed<Granularity: Unit & LTOEEra> {

#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<Calendar.Component> {
return Calendar.Component.from(lower: Granularity.self, to: Era.self)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Time/6-Adjustments/Fixed+SafeAdjustment.swift
Expand Up @@ -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
}
Expand Down
14 changes: 14 additions & 0 deletions Sources/Time/Documentation.docc/ReleaseNotes.md
Expand Up @@ -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
5 changes: 3 additions & 2 deletions Sources/Time/Internals/Fixed+Internal.swift
Expand Up @@ -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?
Expand Down

0 comments on commit f827477

Please sign in to comment.