A Swift micro-library for type-safe time calculations with strongly-typed intervals.
Time is a Swift micro-library that provides type-safe time calculations using strongly-typed intervals. It solves the problem of error-prone time representations (like using raw `TimeInterval` values) by offering clear, unit-specific types for seconds, minutes, hours, and more. This ensures compile-time safety and expressive syntax for time-based operations.
Swift developers working on iOS, macOS, or other Apple platform apps who need to handle time calculations, scheduling, or date manipulations. It’s especially useful for those prioritizing code safety and readability.
Developers choose Time over raw Foundation APIs because it eliminates common time-related bugs through strong typing, offers intuitive syntax (e.g., `10.minutes`), and integrates seamlessly with Swift and Foundation types like `Date` and `DispatchQueue`.
🕰 Type-safe time calculations in Swift
Prevents common time calculation errors by using distinct types for each unit (e.g., Interval<Minute>), ensuring compile-time checks instead of runtime bugs, as highlighted in the README's philosophy.
Offers intuitive syntax like `10.minutes` and seamless integration with Foundation's Date and DispatchQueue, making code more readable and reducing boilerplate, as shown in the usage examples.
Supports easy conversions between units via properties like `.inSeconds` and methods like `converted(to:)`, allowing arithmetic across different units without manual math, demonstrated in the operations section.
Allows defining custom units like weeks by conforming to the TimeUnit protocol, extending functionality to specific needs, with clear examples provided in the README for implementation.
Focuses solely on time intervals without built-in support for higher-level concepts like time zones, calendars, or date manipulations beyond basic additions, requiring additional libraries for full date-time handling.
Officially supports only Swift Package Manager, with Carthage and CocoaPods deprecated beyond version 1.0.1, which can be a barrier for projects using older dependency management systems, as noted in the installation section.
As a micro-library with just two files, it lacks the extensive tooling, documentation, and community support of larger frameworks, which might affect long-term maintenance and integration for complex projects.
🐔 Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift.
Dates and times made easy in iOS
Intuitive date handling in Swift
Robust and type-safe date and time calculations for Swift
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.