Introduction
Welcome to the documentation for DateToolsSwift, a powerful Swift library for working with dates and times. Whether you need to calculate time differences, create recurring events, or format dates, DateToolsSwift has you covered.
Installation
To install DateToolsSwift, you have a few options:
- Using CocoaPods:
pod 'DateToolsSwift'
github "MatthewYork/DateTools"
.package(url: "https://github.com/MatthewYork/DateTools.git", .upToNextMajor(from: "3.0.0"))
Usage
To begin using DateToolsSwift, import the module into your Swift file:
import DateToolsSwift
Calculating Time Differences
DateToolsSwift provides various methods to calculate time differences between dates. For example:
timeIntervalSince(date: Date) -> TimeInterval
yearsFrom(date: Date) -> Int
monthsFrom(date: Date) -> Int
weeksFrom(date: Date) -> Int
daysFrom(date: Date) -> Int
hoursFrom(date: Date) -> Int
minutesFrom(date: Date) -> Int
secondsFrom(date: Date) -> Int
Formatting Dates
Formatting dates is made straightforward with the extensive set of predefined formats provided by DateToolsSwift. Some of the available methods include:
formatted(format: String) -> String
shortTimeString() -> String
shortDateString() -> String
shortString() -> String
Creating Recurring Events
DateToolsSwift allows you to easily create recurring events with its RecurrenceRule class. Examples of available methods include:
recurringDates(withCount: Int) -> [Date]
recurringDates(within: DateInterval) -> [Date]
recurringDates(startingFrom: Date, until: Date) -> [Date]
Handling Time Zones
DateToolsSwift simplifies working with different time zones. You can convert dates to another time zone using methods like:
convertTo(timeZone: TimeZone) -> Date
convertTo(region: Region) -> Date
Conclusion
This documentation has provided a brief overview of the powerful date and time manipulation capabilities offered by DateToolsSwift. We encourage you to explore the library further and make the most of its extensive functionality in your Swift projects.