title: first and last day of the current month in swift
body: <p>I'm trying to get the first and last day of the month in swift.</p>
  
  <p>So far I have the following:</p>
  
  <pre><code>let dateFormatter = NSDateFormatter()
  let date = NSDate()
  dateFormatter.dateFormat = "yyyy-MM-dd"
  let calendar = NSCalendar.currentCalendar()
  let components = calendar.components([.Year, .Month, .Day, .Hour, .Minute, .Second], fromDate: date)
  
  let month = components.month
  let year = components.year
  
  let startOfMonth = ("\(year)-\(month)-01")
  </code></pre>
  
  <p>But I'm not sure how to get the last date. Is there a built in method I'm missing? Obviously it has to take into account leap years etc.</p>