Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright © 2014 by Orlando Aleman Ortiz @orlandoaleman. Some rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 changes: 17 additions & 0 deletions NSDate+HumanInterval.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

Pod::Spec.new do |s|
s.name = "NSDate+HumanInterval"
s.version = "0.0.2"
s.summary = "Category that adds a method that returns an human-readable representation of the NSDate"
s.description = "Category that adds a method that returns an human-readable representation of the NSDate:
* To easily translate date strings to human readable representation
* Current supported languages: Spanish and English"
s.homepage = "https://github.com/orlandoaleman/NSDate-HumanInterval"
s.license = {:type => 'MIT', :file => 'LICENSE'}
s.authors = { "David E. Wheeler" => "[email protected]", "Orlando Aleman Ortiz" => "[email protected]"}
s.platform = :ios, '5.0'
s.source = { :git => "https://github.com/orlandoaleman/NSDate-HumanInterval.git", :tag => "0.0.2" }
s.source_files = 'src/*.{h,m}'
s.resources = "Shared/HILanguages.bundle"
s.frameworks = 'Foundation'
end
39 changes: 23 additions & 16 deletions NSDate+HumanInterval.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 45;
objectVersion = 46;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -15,12 +15,13 @@
2860E32E111B888700E27156 /* AppDelegate_iPad.m in Sources */ = {isa = PBXBuildFile; fileRef = 2860E32C111B888700E27156 /* AppDelegate_iPad.m */; };
2860E32F111B888700E27156 /* MainWindow_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2860E32D111B888700E27156 /* MainWindow_iPad.xib */; };
288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; };
5566749A18DDFD8100FA3C81 /* HILanguages.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 5566749918DDFD8100FA3C81 /* HILanguages.bundle */; };
5576C25C18DDFA0A00674456 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 5576C25B18DDFA0A00674456 /* [email protected] */; };
6326A80E120FB469000A8FFF /* NSDate+HumanInterval.m in Sources */ = {isa = PBXBuildFile; fileRef = 6326A80D120FB469000A8FFF /* NSDate+HumanInterval.m */; };
6326A84E120FB6C6000A8FFF /* HumanIntervalTest.m in Resources */ = {isa = PBXBuildFile; fileRef = 6326A82E120FB5C8000A8FFF /* HumanIntervalTest.m */; };
6326A84F120FB6C6000A8FFF /* NSDate+HumanInterval.m in Resources */ = {isa = PBXBuildFile; fileRef = 6326A80D120FB469000A8FFF /* NSDate+HumanInterval.m */; };
6326A850120FB6CF000A8FFF /* HumanIntervalTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 6326A82E120FB5C8000A8FFF /* HumanIntervalTest.m */; };
6326A851120FB6D4000A8FFF /* NSDate+HumanInterval.m in Sources */ = {isa = PBXBuildFile; fileRef = 6326A80D120FB469000A8FFF /* NSDate+HumanInterval.m */; };
63F95FF7162FCEE300DCF83A /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 63F95FF6162FCEE300DCF83A /* [email protected] */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -35,12 +36,13 @@
2860E32D111B888700E27156 /* MainWindow_iPad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow_iPad.xib; sourceTree = "<group>"; };
288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
32CA4F630368D1EE00C91783 /* NSDate_Interval_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSDate_Interval_Prefix.pch; sourceTree = "<group>"; };
5566749918DDFD8100FA3C81 /* HILanguages.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = HILanguages.bundle; path = Shared/HILanguages.bundle; sourceTree = SOURCE_ROOT; };
5566749B18DE037700FA3C81 /* NSDate_Interval_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSDate_Interval_Prefix.pch; sourceTree = "<group>"; };
5576C25B18DDFA0A00674456 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
6326A80C120FB469000A8FFF /* NSDate+HumanInterval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+HumanInterval.h"; sourceTree = "<group>"; };
6326A80D120FB469000A8FFF /* NSDate+HumanInterval.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+HumanInterval.m"; sourceTree = "<group>"; };
6326A82E120FB5C8000A8FFF /* HumanIntervalTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HumanIntervalTest.m; sourceTree = "<group>"; };
6326A839120FB636000A8FFF /* LogicTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LogicTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
63F95FF6162FCEE300DCF83A /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* NSDate_Interval-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "NSDate_Interval-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -77,6 +79,7 @@
2860E324111B887F00E27156 /* iPhone */ = {
isa = PBXGroup;
children = (
5576C25B18DDFA0A00674456 /* [email protected] */,
2860E325111B887F00E27156 /* AppDelegate_iPhone.h */,
2860E326111B887F00E27156 /* AppDelegate_iPhone.m */,
2860E327111B887F00E27156 /* MainWindow_iPhone.xib */,
Expand All @@ -97,16 +100,17 @@
28EEBF621118D79A00187D67 /* Shared */ = {
isa = PBXGroup;
children = (
5566749B18DE037700FA3C81 /* NSDate_Interval_Prefix.pch */,
29B97316FDCFA39411CA2CEA /* main.m */,
8D1107310486CEB800E47090 /* NSDate_Interval-Info.plist */,
5566749918DDFD8100FA3C81 /* HILanguages.bundle */,
);
path = Shared;
sourceTree = "<group>";
};
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
isa = PBXGroup;
children = (
63F95FF6162FCEE300DCF83A /* [email protected] */,
2860E32A111B888700E27156 /* iPad */,
2860E324111B887F00E27156 /* iPhone */,
28EEBF621118D79A00187D67 /* Shared */,
Expand All @@ -123,7 +127,6 @@
children = (
6326A80C120FB469000A8FFF /* NSDate+HumanInterval.h */,
6326A80D120FB469000A8FFF /* NSDate+HumanInterval.m */,
32CA4F630368D1EE00C91783 /* NSDate_Interval_Prefix.pch */,
);
path = src;
sourceTree = "<group>";
Expand Down Expand Up @@ -189,12 +192,16 @@
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0510;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "NSDate+HumanInterval" */;
compatibilityVersion = "Xcode 3.1";
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
en,
es,
);
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
projectDirPath = "";
Expand All @@ -211,9 +218,10 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5576C25C18DDFA0A00674456 /* [email protected] in Resources */,
5566749A18DDFD8100FA3C81 /* HILanguages.bundle in Resources */,
2860E329111B887F00E27156 /* MainWindow_iPhone.xib in Resources */,
2860E32F111B888700E27156 /* MainWindow_iPad.xib in Resources */,
63F95FF7162FCEE300DCF83A /* [email protected] in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -276,8 +284,8 @@
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = NSDate_Interval_Prefix.pch;
INFOPLIST_FILE = "NSDate_Interval-Info.plist";
GCC_PREFIX_HEADER = Shared/NSDate_Interval_Prefix.pch;
INFOPLIST_FILE = "$(SRCROOT)/Shared/NSDate_Interval-Info.plist";
PRODUCT_NAME = "NSDate-Interval";
SDKROOT = iphoneos;
};
Expand All @@ -289,8 +297,8 @@
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = NSDate_Interval_Prefix.pch;
INFOPLIST_FILE = "NSDate_Interval-Info.plist";
GCC_PREFIX_HEADER = Shared/NSDate_Interval_Prefix.pch;
INFOPLIST_FILE = "$(SRCROOT)/Shared/NSDate_Interval-Info.plist";
PRODUCT_NAME = "NSDate-Interval";
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand Down Expand Up @@ -360,30 +368,29 @@
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 3.2;
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
SDKROOT = iphoneos4.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 3.2;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PREBINDING = NO;
SDKROOT = iphoneos4.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ NSDate+HumanInterval

An Objective-C category that adds a single method to `NSDate`:
`-humanIntervalSinceNow`. This method returns an `NSString` with a
human-readable (English) representation of the `NSDate`, relative to now. The
human-readable (English, Spanish) representation of the `NSDate`, relative to now. The
default values are short, for use on the iPhone. Some examples:

* "just now": Less than 30 seconds ago.
Expand Down Expand Up @@ -35,10 +35,12 @@ Then just call `humanIntervalSinceNow` on an `NSDate` object:
If you'd like to run the unit tests, open `NSDate+HumanInterval.xcodeproj` in
Xcode and build the "UnitTesting" target.


Author
------

[David E. Wheeler](http://justatheory.com/)
* [David E. Wheeler](http://justatheory.com/)
* [Orlando Aleman](http://orlandoaleman.com/)

Copyright and License
---------------------
Expand Down
36 changes: 36 additions & 0 deletions Shared/HILanguages.bundle/en.lproj/NSDate+HumanInterval.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
NSDate+HumanInterval.strings
orlandoaleman.com

Created by Orlando Aleman Ortiz on 27/02/13.
*/

"%u days ago" = "%u days ago";
"%u days" = "%u days";
"%u hours ago" = "%u hours ago";
"%u hours" = "%u hours";
"%u mins" = "%u mins";
"%u minutes ago" = "%u minutes ago";
"%u months ago" = "%u months ago";
"%u months" = "%u months";
"%u weeks ago" = "%u weeks ago";
"%u weeks" = "%u weeks";
"%u years ago" = "%u years ago";
"%u years" = "%u years";
"1 day" = "1 day";
"1 hour" = "1 hour";
"1 min" = "1 min";
"1 week" = "1 week";
"1 year" = "1 year";
"2 days ago" = "2 days ago";
"2 days" = "2 days";
"2 hours ago" = "2 hours ago";
"2 hours" = "2 hours";
"2 weeks ago" = "2 weeks ago";
"2 weeks" = "2 weeks";
"a day ago" = "a day ago";
"a minute ago" = "a minute ago";
"a week ago" = "a week ago";
"a year ago" = "a year ago";
"an hour ago" = "an hour ago";
"just now" = "just now";
36 changes: 36 additions & 0 deletions Shared/HILanguages.bundle/es.lproj/NSDate+HumanInterval.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
NSDate+HumanInterval.strings
orlandoaleman.com

Created by Orlando Aleman Ortiz on 27/02/13.
*/

"%u days ago" = "hace %u días";
"%u days" = "%u días";
"%u hours ago" = "hace %u horas";
"%u hours" = "%u horas";
"%u mins" = "%u mins";
"%u minutes ago" = "hace %u minutos";
"%u months ago" = "hace %u meses";
"%u months" = "%u meses";
"%u weeks ago" = "hace %u semanas";
"%u weeks" = "%u semanas";
"%u years ago" = "hace %u años";
"%u years" = "%u años";
"1 day" = "1 día";
"1 hour" = "1 hora";
"1 min" = "1 min";
"1 week" = "1 semana";
"1 year" = "1 año";
"2 days ago" = "hace 2 días";
"2 days" = "2 días";
"2 hours ago" = "hace 2 horas";
"2 hours" = "2 horas";
"2 weeks ago" = "hace 2 semanas";
"2 weeks" = "2 semanas";
"a day ago" = "hace un día";
"a minute ago" = "hace un minuto";
"a week ago" = "hace una semana";
"a year ago" = "hace un año";
"an hour ago" = "hace una hora";
"just now" = "ahora";
File renamed without changes.
35 changes: 20 additions & 15 deletions iPad/AppDelegate_iPad.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,54 @@ @implementation AppDelegate_iPad
#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.

[window makeKeyAndVisible];
return YES;

return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
- (void)applicationWillResignActive:(UIApplication *)application
{
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
- (void)applicationDidBecomeActive:(UIApplication *)application
{
/*
Restart any tasks that were paused (or not yet started) while the application was inactive.
Restart any tasks that were paused (or not yet started) while the application was inactive.
*/
}


- (void)applicationWillTerminate:(UIApplication *)application {
- (void)applicationWillTerminate:(UIApplication *)application
{
/*
Called when the application is about to terminate.
Called when the application is about to terminate.
*/
}


#pragma mark -
#pragma mark Memory management

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}


- (void)dealloc {
- (void)dealloc
{
[window release];
[super dealloc];
}
Expand Down
File renamed without changes
Loading