Latest 0.0.1
Homepage https://github.com/atomkirk/Jumper
License MIT
Platforms ios 9.0, osx 10.11, watchos 2.0, tvos 9.0
Authors

Small extension to Date for 95% of use cases.

Description

The native Date API for Swift/Cocoa is tedious and clunky. With years of
experience working with these APIs, I’ve distilled 95% of use cases to just a
handful of methods added to Date. The methods are short and easy to remember
and the parameters are enums so you get auto completion for possible values.

Creating Dates

Date(ISOString: "2018-02-01T03:04:01")
Date(string: "2018-02-01" format: "YYYY-MM-dd")
Date([.year: 2015])

Moving

date.change([.day: 4]) // 2018-02-04

date.move([.months: 3]) // 2018-05-04

date.clamp(to: .end, of: .month, -1) // '-1' is optional offset. So end of previous month: 2018-02-29 23:59:59

Measuring

date.what(.day, of: .year) // 234

date.diff(.years, .since, date2) // 20

date.count(.days, in: .month, +1) // '+1' is optional offset. So number of days in next month: 31

Comparing

date.within(same: .month, of: date2) // true/false

Formatting

date.string("YYYY-MM-dd") //=> "Jun 03 2015"

NSDateFormatter.symbols(.weekday, .veryShort) // ["S", "M", "T", "W", "T", "F", "S"]

Global settings

Jumper uses the Calendar.current calendar by default. You can assign a new
calendar to Jumper.calendar = Calendar(identifier: .gregorian)

If you change any of the following values on Jumper.calendar they will be used
in calculations:

  • locale
  • time zone
  • first day of week
  • week numbering system

Latest podspec

{
    "name": "Jumper",
    "version": "0.0.1",
    "summary": "Small extension to Date for 95% of use cases",
    "description": "The native Date API for Swift/Cocoa is tedious and clunky. With years ofnexperience working with these APIs, I've distilled 95% of use cases to just anhandful of methods added to Date. The methods are short and easy to remembernand the parameters are enums so you get auto completion for possible values.nJust check out the README for a quick summary and then don't be suprised if younnever need to look at the docs again!",
    "homepage": "https://github.com/atomkirk/Jumper",
    "license": "MIT",
    "authors": {
        "Adam Kirk": "[email protected]"
    },
    "platforms": {
        "ios": "9.0",
        "osx": "10.11",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source": {
        "git": "https://github.com/atomkirk/Jumper.git",
        "tag": "v0.0.1"
    },
    "source_files": "Jumper"
}

Pin It on Pinterest

Share This