From 7c8a2094aa66485fef82290c07f748b8da3eb94f Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 9 Dec 2014 11:04:31 -0600 Subject: [PATCH] Adds a fuzzy date format based on NSDate+TimeAgo. Plan on converting to https://github.com/MatthewYork/DateTools/tree/master/DateTools once I get feedback from project. See https://github.com/MatthewYork/DateTools/issues/26 --- CoreDataUtil.xcodeproj/project.pbxproj | 34 ++ CoreDataUtil/MFLMainWindowController.m | 8 +- CoreDataUtil/MFLMainWindowController.xib | 16 +- .../Utils/extensions/timeago/NSDate+TimeAgo.h | 21 + .../Utils/extensions/timeago/NSDate+TimeAgo.m | 491 ++++++++++++++++++ .../ar.lproj/NSDateTimeAgo.strings | Bin 0 -> 3332 bytes .../bg.lproj/NSDateTimeAgo.strings | 71 +++ .../cs.lproj/NSDateTimeAgo.strings | 71 +++ .../da.lproj/NSDateTimeAgo.strings | 71 +++ .../de.lproj/NSDateTimeAgo.strings | 71 +++ .../en.lproj/NSDateTimeAgo.strings | 71 +++ .../es.lproj/NSDateTimeAgo.strings | 71 +++ .../fi.lproj/NSDateTimeAgo.strings | 71 +++ .../fr.lproj/NSDateTimeAgo.strings | 71 +++ .../gre.lproj/NSDateTimeAgo.strings | Bin 0 -> 3494 bytes .../he.lproj/NSDateTimeAgo.strings | 71 +++ .../hu.lproj/NSDateTimeAgo.strings | 71 +++ .../is.lproj/NSDateTimeAgo.strings | 71 +++ .../it.lproj/NSDateTimeAgo.strings | 71 +++ .../ja.lproj/NSDateTimeAgo.strings | 71 +++ .../ko.lproj/NSDateTimeAgo.strings | 71 +++ .../lv.lproj/NSDateTimeAgo.strings | 24 + .../nb.lproj/NSDateTimeAgo.strings | 125 +++++ .../nl.lproj/NSDateTimeAgo.strings | 71 +++ .../pl.lproj/NSDateTimeAgo.strings | 71 +++ .../pt-PT.lproj/NSDateTimeAgo.strings | 71 +++ .../pt.lproj/NSDateTimeAgo.strings | 71 +++ .../ro.lproj/NSDateTimeAgo.strings | 71 +++ .../ru.lproj/NSDateTimeAgo.strings | 125 +++++ .../sq.lproj/NSDateTimeAgo.strings | 71 +++ .../sv.lproj/NSDateTimeAgo.strings | Bin 0 -> 3430 bytes .../th.lproj/NSDateTimeAgo.strings | Bin 0 -> 3462 bytes .../tr.lproj/NSDateTimeAgo.strings | 71 +++ .../uk.lproj/NSDateTimeAgo.strings | 125 +++++ .../vi.lproj/NSDateTimeAgo.strings | 71 +++ .../zh-Hans.lproj/NSDateTimeAgo.strings | 71 +++ .../zh-Hant.lproj/NSDateTimeAgo.strings | 71 +++ 37 files changed, 2664 insertions(+), 9 deletions(-) create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDate+TimeAgo.h create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDate+TimeAgo.m create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/ar.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/bg.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/cs.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/da.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/de.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/en.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/es.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/fi.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/fr.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/gre.lproj/NSDateTimeAgo.strings create mode 100755 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/he.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/hu.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/is.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/it.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/ja.lproj/NSDateTimeAgo.strings create mode 100755 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/ko.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/lv.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/nb.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/nl.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/pl.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/pt-PT.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/pt.lproj/NSDateTimeAgo.strings create mode 100755 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/ro.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/ru.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/sq.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/sv.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/th.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/tr.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/uk.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/vi.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/zh-Hans.lproj/NSDateTimeAgo.strings create mode 100644 CoreDataUtil/Utils/extensions/timeago/NSDateTimeAgo.bundle/zh-Hant.lproj/NSDateTimeAgo.strings diff --git a/CoreDataUtil.xcodeproj/project.pbxproj b/CoreDataUtil.xcodeproj/project.pbxproj index 9b14876..26b9092 100644 --- a/CoreDataUtil.xcodeproj/project.pbxproj +++ b/CoreDataUtil.xcodeproj/project.pbxproj @@ -30,6 +30,12 @@ 83656E6619378FB7003D0E74 /* CoreDataUtilityStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 83656E6519378FB7003D0E74 /* CoreDataUtilityStyle.m */; }; 83656E6E1937A73B003D0E74 /* ObjectInfoController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83656E6C1937A73B003D0E74 /* ObjectInfoController.m */; }; 83656E6F1937A73B003D0E74 /* ObjectInfoController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 83656E6D1937A73B003D0E74 /* ObjectInfoController.xib */; }; + 8373BBB41A3740B3009E0297 /* NSDate+TimeAgo.m in Sources */ = {isa = PBXBuildFile; fileRef = 8373BBB21A3740B3009E0297 /* NSDate+TimeAgo.m */; }; + 8373BBB51A3740B3009E0297 /* NSDate+TimeAgo.m in Sources */ = {isa = PBXBuildFile; fileRef = 8373BBB21A3740B3009E0297 /* NSDate+TimeAgo.m */; }; + 8373BBB61A3740B3009E0297 /* NSDate+TimeAgo.m in Sources */ = {isa = PBXBuildFile; fileRef = 8373BBB21A3740B3009E0297 /* NSDate+TimeAgo.m */; }; + 8373BBB71A3740B3009E0297 /* NSDateTimeAgo.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 8373BBB31A3740B3009E0297 /* NSDateTimeAgo.bundle */; }; + 8373BBB81A3740B3009E0297 /* NSDateTimeAgo.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 8373BBB31A3740B3009E0297 /* NSDateTimeAgo.bundle */; }; + 8373BBB91A3740B3009E0297 /* NSDateTimeAgo.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 8373BBB31A3740B3009E0297 /* NSDateTimeAgo.bundle */; }; 837C067B1A0E646600F4D5D4 /* MFLBuild.m in Sources */ = {isa = PBXBuildFile; fileRef = 837C067A1A0E646600F4D5D4 /* MFLBuild.m */; }; 838055C915A3A67200D050E7 /* ApplicationIcon-CDP.icns in Resources */ = {isa = PBXBuildFile; fileRef = 838055C715A3A67200D050E7 /* ApplicationIcon-CDP.icns */; }; 838055CA15A3A67200D050E7 /* ApplicationIcon-MOM.icns in Resources */ = {isa = PBXBuildFile; fileRef = 838055C815A3A67200D050E7 /* ApplicationIcon-MOM.icns */; }; @@ -131,6 +137,9 @@ 83656E6B1937A73B003D0E74 /* ObjectInfoController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectInfoController.h; sourceTree = ""; }; 83656E6C1937A73B003D0E74 /* ObjectInfoController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectInfoController.m; sourceTree = ""; }; 83656E6D1937A73B003D0E74 /* ObjectInfoController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ObjectInfoController.xib; sourceTree = ""; }; + 8373BBB11A3740B3009E0297 /* NSDate+TimeAgo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+TimeAgo.h"; sourceTree = ""; }; + 8373BBB21A3740B3009E0297 /* NSDate+TimeAgo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+TimeAgo.m"; sourceTree = ""; }; + 8373BBB31A3740B3009E0297 /* NSDateTimeAgo.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = NSDateTimeAgo.bundle; sourceTree = ""; }; 837C06791A0E646600F4D5D4 /* MFLBuild.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFLBuild.h; sourceTree = ""; }; 837C067A1A0E646600F4D5D4 /* MFLBuild.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFLBuild.m; sourceTree = ""; }; 838055C715A3A67200D050E7 /* ApplicationIcon-CDP.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = "ApplicationIcon-CDP.icns"; sourceTree = ""; }; @@ -214,6 +223,7 @@ 832C9698159BDB8600AC8FA8 /* Utils */ = { isa = PBXGroup; children = ( + 8373BBAF1A37408D009E0297 /* extensions */, 833FF6FB187860F1003ADCEA /* MFLConstants.h */, 833FF6FC187860F1003ADCEA /* MFLConstants.m */, 832C9699159BDBB000AC8FA8 /* MFLCoreDataEditorProjectLoader.h */, @@ -259,6 +269,24 @@ name = windows; sourceTree = ""; }; + 8373BBAF1A37408D009E0297 /* extensions */ = { + isa = PBXGroup; + children = ( + 8373BBB01A3740B3009E0297 /* timeago */, + ); + path = extensions; + sourceTree = ""; + }; + 8373BBB01A3740B3009E0297 /* timeago */ = { + isa = PBXGroup; + children = ( + 8373BBB11A3740B3009E0297 /* NSDate+TimeAgo.h */, + 8373BBB21A3740B3009E0297 /* NSDate+TimeAgo.m */, + 8373BBB31A3740B3009E0297 /* NSDateTimeAgo.bundle */, + ); + path = timeago; + sourceTree = ""; + }; 83AE7D2D19FF1A9500DD152B /* simulator */ = { isa = PBXGroup; children = ( @@ -534,6 +562,7 @@ buildActionMask = 2147483647; files = ( C1CEFE601463779D00466EB3 /* InfoPlist.strings in Resources */, + 8373BBB71A3740B3009E0297 /* NSDateTimeAgo.bundle in Resources */, C1CEFE661463779D00466EB3 /* Credits.rtf in Resources */, C1CEFE6C1463779D00466EB3 /* MainMenu.xib in Resources */, C1CEFE8B1463779D00466EB3 /* CoreDataUtilImporter.mdimporter in Resources */, @@ -556,6 +585,7 @@ buildActionMask = 2147483647; files = ( C1CEFE801463779D00466EB3 /* InfoPlist.strings in Resources */, + 8373BBB81A3740B3009E0297 /* NSDateTimeAgo.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -564,6 +594,7 @@ buildActionMask = 2147483647; files = ( C1CEFE991463779D00466EB3 /* InfoPlist.strings in Resources */, + 8373BBB91A3740B3009E0297 /* NSDateTimeAgo.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -628,6 +659,7 @@ 5BE26B63157FE8EE00DC186E /* EntityTableView.m in Sources */, 83AE7D3019FF1AB400DD152B /* SimulatorItem.m in Sources */, 5BE26B67157FF22700DC186E /* EntityDataTableView.m in Sources */, + 8373BBB41A3740B3009E0297 /* NSDate+TimeAgo.m in Sources */, 83B158FD158F6AE2002B46C2 /* MFLCoreDataIntrospection.m in Sources */, 5B330A701590CB1E00D79D4D /* EntityDataTableViewCell.m in Sources */, 835941221592351D0045B287 /* MFLCoreDataCommon.m in Sources */, @@ -648,6 +680,7 @@ buildActionMask = 2147483647; files = ( C1CEFE831463779D00466EB3 /* CoreDataUtilTests.m in Sources */, + 8373BBB51A3740B3009E0297 /* NSDate+TimeAgo.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -658,6 +691,7 @@ C1CEFE9B1463779D00466EB3 /* main.c in Sources */, C1CEFE9D1463779D00466EB3 /* GetMetadataForFile.m in Sources */, C1CEFEA01463779D00466EB3 /* MySpotlightImporter.m in Sources */, + 8373BBB61A3740B3009E0297 /* NSDate+TimeAgo.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/CoreDataUtil/MFLMainWindowController.m b/CoreDataUtil/MFLMainWindowController.m index 2311a30..23381d9 100644 --- a/CoreDataUtil/MFLMainWindowController.m +++ b/CoreDataUtil/MFLMainWindowController.m @@ -17,6 +17,7 @@ #import "FetchRequestInfoController.h" #import "ObjectInfoController.h" #import "MFLUtils.h" +#import "NSDate+TimeAgo.h" // max length of text to display in cell static const int MAX_TEXT_LENGTH = 255; @@ -452,7 +453,12 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn else if ([valueObj isKindOfClass:[NSDate class]]) { viewType = ViewTypeDate; [self setupDateFormatter]; - viewText = [self.dateFormatter stringFromDate:valueObj]; + if (self.dateStyle == NSDateFormatterShortStyle) { + viewText = [valueObj timeAgo]; + + } else { + viewText = [self.dateFormatter stringFromDate:valueObj]; + } } else if ([valueObj isKindOfClass:[NSURL class]]) { viewType = ViewTypeLink; diff --git a/CoreDataUtil/MFLMainWindowController.xib b/CoreDataUtil/MFLMainWindowController.xib index 42d96d5..ce255ea 100644 --- a/CoreDataUtil/MFLMainWindowController.xib +++ b/CoreDataUtil/MFLMainWindowController.xib @@ -1,8 +1,8 @@ - + - + @@ -165,7 +165,7 @@ - +