DNTimeAndDay 0.2.1

DNTimeAndDay 0.2.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2016
SPMSupports SPM

Maintained by Daniel.



  • By
  • dnomnom

DNTimeAndDay

A simple/swifty take on NSDate/NSDateFormatter/NSDateComponent. A DNTimeAndDay object can be initialized with a string value, int value, or date object. The object returns a stringValue in various formats and changes the time and day at a given interval. Only supports Time and Day of the Week at the moment

Installation

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

pod "DNTimeAndDay"

Example

To run the example project, clone the repo,

git clone https://github.com/dknomura/DNTimeAndDay.git

and run

pod install

from the Example directory.

Usage

var currentTimeAndDay = DNTimeAndDay.currentTimeAndDay()  
// can also init with string and int values
// day string parameter is case insensitive and can recognize common day abbreviations, time string can have a period or colon and the option of am/pm (ie "11:30p", "11.5p", "11:00pm", "23.5", "23:30" are all the same) 
// default minuteInterval = 30, dayInterval = 1
var otherTimeAndDay = DNTimeAndDay.init(dayString: "m", timeString:"9p", minuteInterval: 90, dayInterval = 2)

otherTimeAndDay.increaseTime()  
otherTimeAndDay.time.stringValue(forFormat:.format12Hour)  // "10:30pm"
// if the time is in between intervals, then the minute will increase to match the interval. 
// ie time = 12:00pm, not 12;15pm

currentTimeAndDay.increaseDay() 
currentTimeAndDay.day.stringValue(forFormat:.abbr) // "Wed"

Requirements

  • iOS 9.3+
  • Xcode 7.3.1+

Author

dnomnom, [email protected]

License

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