Skip to content

Commit

Permalink
Fix for .weekOfMonth
Browse files Browse the repository at this point in the history
  • Loading branch information
malcommac committed Oct 29, 2015
1 parent 2e59b15 commit e303511
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
13 changes: 9 additions & 4 deletions ExampleProject/ExampleProject/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()


print(NSDate())
print(NSDate().weekOfMonth)

return

let date = NSDate()

_ = date.toString(format: DateFormat.Custom("YYYY-MM-DD"))


_ = date+1.day
let two_months_ago = date-2.months
_ = date+1.days
let two_months_ago = (date-2.months)!
print(two_months_ago.toLongDateString())


Expand All @@ -31,7 +36,7 @@ class ViewController: UIViewController {
print(date_as_utc.toLongTimeString())
print(date_as_beijing?.toLongTimeString())

let d = NSDate()-1.hour
let d = (NSDate()-1.hours)!

print(d.year)

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ date = date.set(componentsDict: ["hour":12,"minute":55]); // Returns a new NSDat
You can add single components to an existing date very easily:
```swift
let date = NSDate()
let tomorrow = date+1.day
let tomorrow = date+1.days
let 2_months_ago = date-2.months
let next_year_today = date+1.year
let next_year_today = date+1.years
let another_date = date+54.seconds
if date1+1.week == date2-1.month {
if date1+1.week == date2-1.months {
// some good stuff to do...
}
```
Expand Down
1 change: 1 addition & 0 deletions SwiftDate/SwiftDate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ private extension NSDate {
NSCalendarUnit.Minute ,
NSCalendarUnit.Second ,
NSCalendarUnit.Weekday ,
NSCalendarUnit.WeekOfMonth ,
NSCalendarUnit.WeekdayOrdinal,
NSCalendarUnit.WeekOfYear]
}
Expand Down

0 comments on commit e303511

Please sign in to comment.