Perform calculations with dates:
aDate + 2.weeks + 1.hours or (1.years - 2.hours + 16.minutes).fromNow()
- Easy conversions to and from
calendar. Use helper class
DateInRegionand perform conversions with components and operations!
- Compare dates with math operators
<,>,==,<=,>=. For example you can do
aDate1 >= aDate2or
- Easily get time components. E.g.
- Easy/optimized way to get and transform a date from and to strings (with relative date supports* like
'2 hours, 5 minutes'etc.)
- Express time interval in other time units; for example
120.seconds.in(.minutes) // 2 minutes
- Many shortcuts to get intervals and common dates (
- ... many many other shiny things!
Actually current official version is 4 and it's compatible with:
- Swift 3.0+
- iOS 8 or later
- macOS 10.10 or later
- watchOS 2.0 or later
- tvOS 9.0 or later
- ...and virtually any platform which is compatible with Swift 3 and implements the Swift Foundation Library
SwiftDate supports multiple methods for installing the library in a project.
Installation with CocoaPods
CocoaPods is a dependency manager for Objective-C and Swift, which automates and simplifies the process of using 3rd-party libraries like SwiftDate in your projects.
You can install it with the following command:
$ gem install cocoapods
To integrate SwiftDate into your Xcode project using CocoaPods, specify it in your Podfile:
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' target 'TargetName' do pod 'SwiftDate', '~> 4.0' end
Installation with Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install
Carthage with Homebrew using the following command:
$ brew update $ brew install carthageTo integrate SwiftDate into your Xcode project using Carthage, specify it in your
github "malcommac/SwiftDate" ~> 4.0
Installation with Swift Package Manager
Currently not available
Fork us on GitHub
SwiftDate is opensource and hosted on GitHub.
If you want to contribute there are several ways you can do it:
- If you found a bug, and can provide steps to reliably reproduce it, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
- You can help us to translate our bundle resource which is used to output human readable date representation. See SwiftDate.bundle file.
Authors & License
As open source creation any help is welcome too!
The code of this library is licensed under MIT License; you can use it in commercial products without any limitation.
The only requirement is to add a line in your Credits/About section with the text below:
Date and Time Management is provided by SwiftDate - http://www.swift-date.com Created by Daniele Margutti and licensed under MIT License.
Your App & SwiftDate
If you want we are interested in making a list of all projects which uses this library. Feel free to open an Issue on GitHub so with the name and links of your project; we'll add it to this site.