Skip to content

Midhun-MP/Past

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Past

NSDate extension for easily getting the difference between two dates in terms of Year, Month, Week, Day, Hour, Minute and Second

###Cocoapod

pod 'Past'

In Swift use import Past and in Objective-C use #import <Past/Past-Swift.h> for importing the library.

###Constants

enum PastOptions : Int
{
    case Seconds
    case Minutes
    case Hours
    case Days
    case Weeks
    case Months
    case Years
    
    static let AllValues = [Seconds, Minutes, Hours, Days, Weeks, Months, Years]
}

Defines in which type the result should be given (Whether the difference should be given in terms of seconds or minutes or etc)

###Available Methods

  • isToday() -> Bool

    Checks whether the date is today or not

  • isYesterday() -> Bool

    Checks whether the date was yesterday or not

  • isThisWeek() -> Bool

Checks whether the date is in this current week or not

  • isLastWeek() -> Bool

Checks whether the date was in last week or not

  • isThisMonth() -> Bool

    Checks whether the date is in this current month or not

  • isLastMonth() -> Bool

    Checks whether the date was in the last month or not

  • isThisYear() -> Bool

Checks whether the date is in this year or not

  • isLastYear() -> Bool

Checks whether the date was in last year or not

  • getMoment(inTermsOf option : PastOptions) -> String

Returns a formatted moment in terms of passed past option. If the date is two days ago and the passed option is `Days` then the result will be 2 days ago

  • getElapsedSeconds() -> Int

Returns the elapsed seconds

  • getElapsedMinutes() -> Int

Returns the elapsed minutes

  • getElapsedHours() -> Int

Returns the elapsed hours

  • getElapsedDays() -> Int

Returns the elapsed days

  • getElapsedWeeks() -> Int

Returns the elapsed weeks

  • getElapsedMonths() -> Int

Returns the elapsed months

  • getElapsedYears() -> Int

Returns the elapsed years

About

NSDate extension for easily getting the difference between two dates in terms of Year, Month, Week, Day, Hour, Minute and Second

Resources

License

Stars

Watchers

Forks

Packages

No packages published