Latest 0.9.0
Homepage https://github.com/spitzgoby/Tunits
License MIT
Platforms ios 9.0, requires ARC
Authors

Build Status
Version
License
Platform
Twitter

Tunis is an easy to use library for performing date and time calculations in
iOS. Tunits allows you to quickly create an array of all the days in a given
month or find the first day of the next month.

Have comments or suggestsions? Feel free to submit a pull request or find me
on Twitter (@spitzgoby)

Requirements

Requires XCode 6 and iOS 9+ sdk.

Installation

Tunits is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "Tunits"

Usage

Example Project

To run the example project, clone the repo, and run pod install from the Example directory first.

Instance Methods

TimeUnit methods can be used by creating TimeUnit instances.
The NSCalendar.currentCalendar() is used by default, but TimeUnit
instances expose their calendar property so a custom calendar can be
set.


// Instance
let tunit = TimeUnit() // init new TimeUnit object
let daysOfCurrentMonth = tunit.daysOfMonth(NSDate()) // create array of days

// Custom Calendar
let calendar = NSCalendar.currentCalendar()
calendar.firstWeekday = 2 // set first weekday to Monday
let tunit = TimeUnit()
tunit.calendar = calendar
let daysOfCurrentWeek = tunit.daysOfWeek(NSDate())

Static Methods

TimeUnit also has static versions of its instance methods. This makes code
cleaner, but the NSCalendar.currentCalendar() will be used for all
calculations.

// Static
let daysOfCurrentMonth = TimeUnit.daysOfMonth(NSDate()) // create array of days

Date Chaining

In addition to using TimeUnit methods directly, NSDate objects have
been extended to use the TimeUnit methods that return dates. This
means methods can be chained together for complex date selection.

// Method chaining
let endOfNextYear = NSDate().yearAfter().endOfYear() // Last second of next year

Author

Thomas Leu, [email protected]

License

Tunits is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "Tunits",
    "version": "0.9.0",
    "summary": "A date modification library",
    "description": "Tunits is a simple library of convenience functions for creating groups of NSDates",
    "homepage": "https://github.com/spitzgoby/Tunits",
    "license": "MIT",
    "authors": {
        "Thomas Leu": "[email protected]"
    },
    "source": {
        "git": "https://github.com/spitzgoby/Tunits.git",
        "tag": "0.9.0"
    },
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "Tunits": [
            "Pod/Assets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This