Skip to content
This repository has been archived by the owner on Mar 29, 2018. It is now read-only.

added weeks as shortcut for Int extensions #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ExSwift/Int.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ public extension Int {
var year: NSTimeInterval {
return self.years
}

var week: NSTimeInterval {
return 7 * self.days
}

var weeks: NSTimeInterval {
return self.week
}

var days: NSTimeInterval {
return 24 * self.hours
Expand Down
13 changes: 13 additions & 0 deletions ExSwiftTests/IntExtensionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,19 @@ class IntExtensionsSpec: QuickSpec {

}

it("weeks") {
expect(0.weeks) == 0
expect(1.week) == 604800
expect(111.weeks) == 604800 * 111

expect(-1.week) == -604800
expect(-111.weeks) == -604800 * 111

expect(0.year) == 0.years
expect(1.year) == 1.years
expect(1010.year) == 1010.years
}

it("days") {

expect(0.days) == 0
Expand Down