DXTimestamper
DXTimestamper copied to clipboard
A simple yet extensible solution to showing live timestamps on iOS, for past & future NSDates.
DXTimestamper
Usage
To run the example project, clone the repo, and run the example project. Please open the workspace not just the project.
Integrating DXTimestamper
in your project
Features packed
- You can use
DXTimestampLabel
for showing fuzzy timestamps instead of UILabels - You can also use
DXTimestampButton
for showing fuzzy timestamps instead of UIButtons. This gives you flexibility to add custom image as shown in the screenshot, or to implement button events. - The default timestamp will be represented by one of the following entries:
- now => rightnow
- (n) s => n seconds
- (n) m => n minutes
- (n) h => n hours
- (n) d => n days
- (n) w => n weeks
configuration
- Change the class of the
UILabel
toDXTimestampLabel
and change the class ofUIButton
toDXTimestampButton
in storyboard. - Assign a
NSDate
object totimestamp
property of theDXTimestampLabel
orDXTimestampButton
- Timestamp will updated for each second. This works for past time as well as future time.
Using Custom fuzzy logic
You can set your own fuzzy timestamp calculation logic like this
[DXTimestamper setFuzzyTimestampCalculator:^NSString *(NSDate *timestamp) {
// do fuzzy timestamp calculations and return the fuzzy time string
return @"";
}];
The above configuration is global as of now. You need to call it before using any instance that conform to <DXTimestamping>
. If you want to have this logic to be configurable for each individual instance of <DXTimestamping>
objects then just raise an issue. I will try to work on that.
Screenshot
Requirements
- iOS 7 or above
- Requires ARC
Installation
DXTimestamper is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "DXTimestamper"
Author
s3lvin, [email protected]
Notes
If you want more UIKit
components to be supported by DXTimestamping
either raise an issue. Pull requests are also welcome! Thanks for using DXTimestamper
. Happy coding :)
License
DXTimestamper is available under the MIT license. See the LICENSE file for more info.