NSDate

Undocumented

  • Creates a date based on a string and a formatter type. You can ise .ISO8601(nil) to for deducting an ISO8601Format automatically.

    Parameter

    Parameter fromString Date string i.e. 16 July 1972 6:12:00.

    Parameter

    Parameter format The Date Formatter type can be .ISO8601(ISO8601Format?), .DotNet, .RSS, .AltRSS or Custom(String).

    Returns

    Returns A new date

    Declaration

    Swift

    convenience init(fromString string: String, format:DateFormat)

    Parameters

    fromString Date string i.e. "16 July 1972 6

    12:00".

    format The Date Formatter type can be .ISO8601(ISO8601Format?), .DotNet, .RSS, .AltRSS or Custom(String).
  • Returns true if dates are equal while ignoring time.

    Parameter

    Parameter date: The Date to compare.

    Declaration

    Swift

    func isEqualToDateIgnoringTime(date: NSDate) -> Bool

    Parameters

    date

    The Date to compare.

  • Returns Returns true if date is today.

    Declaration

    Swift

    func isToday() -> Bool
  • Returns true if date is tomorrow.

    Declaration

    Swift

    func isTomorrow() -> Bool
  • Returns true if date is yesterday.

    Declaration

    Swift

    func isYesterday() -> Bool
  • Returns true if date are in the same week.

    Parameter

    Parameter date: The date to compare.

    Declaration

    Swift

    func isSameWeekAsDate(date: NSDate) -> Bool

    Parameters

    date

    The date to compare.

  • Returns true if date is this week.

    Declaration

    Swift

    func isThisWeek() -> Bool
  • Returns true if date is next week.

    Declaration

    Swift

    func isNextWeek() -> Bool
  • Returns true if date is last week.

    Declaration

    Swift

    func isLastWeek() -> Bool
  • Returns true if dates are in the same year.

    Parameter

    Parameter date: The date to compare.

    Declaration

    Swift

    func isSameYearAsDate(date: NSDate) -> Bool

    Parameters

    date

    The date to compare.

  • Returns true if date is this year.

    Declaration

    Swift

    func isThisYear() -> Bool
  • Returns true if date is next year.

    Declaration

    Swift

    func isNextYear() -> Bool
  • Returns true if date is last year.

    Declaration

    Swift

    func isLastYear() -> Bool
  • Returns true if date is earlier than date.

    Parameter

    Parameter date: The date to compare.

    Declaration

    Swift

    func isEarlierThanDate(date: NSDate) -> Bool

    Parameters

    date

    The date to compare.

  • Returns true if date is later than date.

    Parameter

    Parameter date: The date to compare.

    Declaration

    Swift

    func isLaterThanDate(date: NSDate) -> Bool

    Parameters

    date

    The date to compare.

  • Returns true if date is in future.

    Declaration

    Swift

    func isInFuture() -> Bool
  • Returns true if date is in past.

    Declaration

    Swift

    func isInPast() -> Bool
  • Creates a new date by adding years

    Declaration

    Swift

    func dateByAddingYears(years: Int) -> NSDate?

    Parameters

    years

    The number of years to add. pass negative values for getting dates in the past

    Return Value

    A new date object

  • Creates a new date by a adding days.

    Parameter

    Parameter days: The number of days to add.

    Returns

    Returns A new date object.

    Declaration

    Swift

    func dateByAddingDays(days: Int) -> NSDate

    Parameters

    days

    The number of days to add.

  • Creates a new date by a adding hours.

    Parameter

    Parameter days: The number of hours to add.

    Returns

    Returns A new date object.

    Declaration

    Swift

    func dateByAddingHours(hours: Int) -> NSDate

    Parameters

    days

    The number of hours to add.

  • Creates a new date by adding minutes.

    Parameter

    Parameter days: The number of minutes to add.

    Returns

    Returns A new date object.

    Declaration

    Swift

    func dateByAddingMinutes(minutes: Int) -> NSDate

    Parameters

    days

    The number of minutes to add.

  • Creates a new date by adding seconds.

    Parameter

    Parameter seconds: The number of seconds to add.

    Returns

    Returns A new date object.

    Declaration

    Swift

    func dateByAddingSeconds(seconds: Int) -> NSDate

    Parameters

    seconds

    The number of seconds to add.

  • Creates a new date from the start of the day.

    Returns

    Returns A new date object.

    Declaration

    Swift

    func dateAtStartOfDay() -> NSDate
  • Creates a new date from the end of the day.

    Returns

    Returns A new date object.

    Declaration

    Swift

    func dateAtEndOfDay() -> NSDate
  • Creates a new date from the start of the week.

    Returns

    Returns A new date object.

    Declaration

    Swift

    func dateAtStartOfWeek() -> NSDate
  • Creates a new date from the end of the week.

    Returns

    Returns A new date object.

    Declaration

    Swift

    func dateAtEndOfWeek() -> NSDate
  • Creates a new date from the first day of the month

    Returns

    Returns A new date object.

    Declaration

    Swift

    func dateAtTheStartOfMonth() -> NSDate
  • Creates a new date from the last day of the month

    Returns

    Returns A new date object.

    Declaration

    Swift

    func dateAtTheEndOfMonth() -> NSDate
  • Creates a new date based on tomorrow.

    Returns

    Returns A new date object.

    Declaration

    Swift

    class func tomorrow() -> NSDate
  • Creates a new date based on yesterdat.

    Returns

    Returns A new date object.

    Declaration

    Swift

    class func yesterday() -> NSDate
  • Gets the number of seconds after a date.

    Parameter

    Parameter date: the date to compare.

    Returns

    Returns The number of seconds

    Declaration

    Swift

    func secondsAfterDate(date: NSDate) -> Int

    Parameters

    date

    the date to compare.

  • Gets the number of seconds before a date.

    Parameter

    Parameter date: The date to compare.

    Returns

    Returns The number of seconds

    Declaration

    Swift

    func secondsBeforeDate(date: NSDate) -> Int

    Parameters

    date

    The date to compare.

  • Gets the number of minutes after a date.

    Parameter

    Parameter date: the date to compare.

    Returns

    Returns The number of minutes

    Declaration

    Swift

    func minutesAfterDate(date: NSDate) -> Int

    Parameters

    date

    the date to compare.

  • Gets the number of minutes before a date.

    Parameter

    Parameter date: The date to compare.

    Returns

    Returns The number of minutes

    Declaration

    Swift

    func minutesBeforeDate(date: NSDate) -> Int

    Parameters

    date

    The date to compare.

  • Gets the number of hours after a date.

    Parameter

    Parameter date: The date to compare.

    Returns

    Returns The number of hours

    Declaration

    Swift

    func hoursAfterDate(date: NSDate) -> Int

    Parameters

    date

    The date to compare.

  • Gets the number of hours before a date.

    Parameter

    Parameter date: The date to compare.

    Returns

    Returns The number of hours

    Declaration

    Swift

    func hoursBeforeDate(date: NSDate) -> Int

    Parameters

    date

    The date to compare.

  • Gets the number of days after a date.

    Parameter

    Parameter date: The date to compare.

    Returns

    Returns The number of days

    Declaration

    Swift

    func daysAfterDate(date: NSDate) -> Int

    Parameters

    date

    The date to compare.

  • Gets the number of days before a date.

    Parameter

    Parameter date: The date to compare.

    Returns

    Returns The number of days

    Declaration

    Swift

    func daysBeforeDate(date: NSDate) -> Int

    Parameters

    date

    The date to compare.

  • Returns the nearest hour.

    Declaration

    Swift

    func nearestHour () -> Int
  • Returns the year component.

    Declaration

    Swift

    func year () -> Int { return self.components().year  }
  • Returns the month component.

    Declaration

    Swift

    func month () -> Int { return self.components().month }
  • Returns the week of year component.

    Declaration

    Swift

    func week () -> Int { return self.components().weekOfYear }
  • Returns the day component.

    Declaration

    Swift

    func day () -> Int { return self.components().day }
  • Returns the hour component.

    Declaration

    Swift

    func hour () -> Int { return self.components().hour }
  • Returns the minute component.

    Declaration

    Swift

    func minute () -> Int { return self.components().minute }
  • Returns the seconds component.

    Declaration

    Swift

    func seconds () -> Int { return self.components().second }
  • Returns the weekday component.

    Declaration

    Swift

    func weekday () -> Int { return self.components().weekday }
  • Returns the nth days component. e.g. 2nd Tuesday of the month is 2.

    Declaration

    Swift

    func nthWeekday () -> Int { return self.components().weekdayOrdinal }
  • Returns the days of the month.

    Declaration

    Swift

    func monthDays () -> Int { return NSCalendar.currentCalendar().rangeOfUnit(NSCalendarUnit.Day, inUnit: NSCalendarUnit.Month, forDate: self).length }
  • Returns the first day of the week.

    Declaration

    Swift

    func firstDayOfWeek () -> Int
  • Returns the last day of the week.

    Declaration

    Swift

    func lastDayOfWeek () -> Int
  • Returns true if a weekday.

    Declaration

    Swift

    func isWeekday() -> Bool
  • Returns true if weekend.

    Declaration

    Swift

    func isWeekend() -> Bool
  • A string representation using short date and time style.

    Declaration

    Swift

    func toString() -> String
  • A string representation based on a format.

    Parameter

    Parameter format: The format of date can be .ISO8601(.ISO8601Format?), .DotNet, .RSS, .AltRSS or Custom(FormatString).

    Returns

    Returns The date string representation

    Declaration

    Swift

    func toString(format format: DateFormat) -> String

    Parameters

    format

    The format of date can be .ISO8601(.ISO8601Format?), .DotNet, .RSS, .AltRSS or Custom(FormatString).

  • A string representation based on custom style.

    Parameter

    Parameter dateStyle: The date style to use.

    Parameter

    Parameter timeStyle: The time style to use.

    Parameter

    Parameter doesRelativeDateFormatting: Enables relative date formatting.

    Returns

    Returns A string representation of the date.

    Declaration

    Swift

    func toString(dateStyle dateStyle: NSDateFormatterStyle, timeStyle: NSDateFormatterStyle, doesRelativeDateFormatting: Bool = false) -> String

    Parameters

    dateStyle

    The date style to use.

    timeStyle

    The time style to use.

    doesRelativeDateFormatting

    Enables relative date formatting.

  • A string representation based on a relative time language. i.e. just now, 1 minute ago etc..

    Declaration

    Swift

    func relativeTimeToString() -> String
  • A string representation of the weekday.

    Declaration

    Swift

    func weekdayToString() -> String
  • A short string representation of the weekday.

    Declaration

    Swift

    func shortWeekdayToString() -> String
  • A very short string representation of the weekday.

    Returns

    Returns String

    Declaration

    Swift

    func veryShortWeekdayToString() -> String
  • A string representation of the month.

    Returns

    Returns String

    Declaration

    Swift

    func monthToString() -> String
  • A short string representation of the month.

    Returns

    Returns String

    Declaration

    Swift

    func shortMonthToString() -> String
  • A very short string representation of the month.

    Returns

    Returns String

    Declaration

    Swift

    func veryShortMonthToString() -> String