SwiftDate

We really ❤ Swift and we use it since the beginning.

We also think that dates and timezones management should be painless: this is the main reason we have created SwiftDate, proability the best way to deal with time in Swift.

It works on iOS, macOS, watchOS, tvOS and virtually on any Swift compatible platform (yeah Linux too!).

Moreover it's free and open source!

Current Stable Release

Current stable release is 4.0.8 for Swift 3

Last Update: 2016-12-01

Changelog: Read CHANGELOG

Old Unsupported Versions

If you need of a Swift 2.2 or 2.3 compatible version you can found then on our GitHub page.

Main Features

Perform calculations with dates:

  • aDate + 2.weeks + 1.hours or (1.years - 2.hours + 16.minutes).fromNow()
  • Easy conversions to and from timezone, locale and calendar. Use helper class DateInRegion and perform conversions with components and operations!
  • Compare dates with math operators <,>,==,<=,>=. For example you can do aDate1 >= aDate2 or aDate1.isIn(anotherDate,.day)
  • Easily get time components. E.g. aDateInRegion.day or hour, minutes etc.
  • 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 (isYesterday,isTomorrow,isBefore()...)
  • ... many many other shiny things!

Requirements

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

Install

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

CocoaPods 1.0.1+ is required to build SwiftDate 4.+.

Podfile

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 carthage
To integrate SwiftDate into your Xcode project using Carthage, specify it in your Cartfile:
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

SwiftDate was created and currently mantained by Daniele Margutti; a main project contributor is Jeroen Houtzager.

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.

Copyright © 2016 Daniele Margutti - All right reserved