Skip to content

pdn1905/SDDateHelper

Repository files navigation

SDDateHelper

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

SDDateHelper is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SDDateHelper', :git => https://github.com/pdn1905/SDDateHelper

How to use:

Import SDDateHelper

Math with Date:

let today = Date() // 21-09-2017 📅
let nextDay = today + 1.day => 22-09-2017 // same with minutes, hours, months, years..

Compare between Dates:

let today = Date() // 21-09-2017
let nextDay = today + 1.day => 22-09-2017 
let bool = today < nextDay => return true

Get Network time (if failed return device time):

SDTime().getNetworkTime { (date) in
    print(date) => return sync network time.
}

Custom services:

SDTime().getNetworkTime(with: ["time1.google.com","time2.google.com"]) { (date) in
  print(date) => return sync network time.
}
  let now = SDTime().now => sync network time.

Author

NgocPhan, [email protected]

License

SDDateHelper is available under the MIT license. See the LICENSE file for more info.