Skip to content

Commit

Permalink
Adds a fuzzy date format based on NSDate+TimeAgo. Plan on converting to
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Wilson committed Dec 9, 2014
1 parent 4869882 commit 7c8a209
Show file tree
Hide file tree
Showing 37 changed files with 2,664 additions and 9 deletions.
34 changes: 34 additions & 0 deletions CoreDataUtil.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -131,6 +137,9 @@
83656E6B1937A73B003D0E74 /* ObjectInfoController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectInfoController.h; sourceTree = "<group>"; };
83656E6C1937A73B003D0E74 /* ObjectInfoController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectInfoController.m; sourceTree = "<group>"; };
83656E6D1937A73B003D0E74 /* ObjectInfoController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ObjectInfoController.xib; sourceTree = "<group>"; };
8373BBB11A3740B3009E0297 /* NSDate+TimeAgo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+TimeAgo.h"; sourceTree = "<group>"; };
8373BBB21A3740B3009E0297 /* NSDate+TimeAgo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+TimeAgo.m"; sourceTree = "<group>"; };
8373BBB31A3740B3009E0297 /* NSDateTimeAgo.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = NSDateTimeAgo.bundle; sourceTree = "<group>"; };
837C06791A0E646600F4D5D4 /* MFLBuild.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFLBuild.h; sourceTree = "<group>"; };
837C067A1A0E646600F4D5D4 /* MFLBuild.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFLBuild.m; sourceTree = "<group>"; };
838055C715A3A67200D050E7 /* ApplicationIcon-CDP.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = "ApplicationIcon-CDP.icns"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -214,6 +223,7 @@
832C9698159BDB8600AC8FA8 /* Utils */ = {
isa = PBXGroup;
children = (
8373BBAF1A37408D009E0297 /* extensions */,
833FF6FB187860F1003ADCEA /* MFLConstants.h */,
833FF6FC187860F1003ADCEA /* MFLConstants.m */,
832C9699159BDBB000AC8FA8 /* MFLCoreDataEditorProjectLoader.h */,
Expand Down Expand Up @@ -259,6 +269,24 @@
name = windows;
sourceTree = "<group>";
};
8373BBAF1A37408D009E0297 /* extensions */ = {
isa = PBXGroup;
children = (
8373BBB01A3740B3009E0297 /* timeago */,
);
path = extensions;
sourceTree = "<group>";
};
8373BBB01A3740B3009E0297 /* timeago */ = {
isa = PBXGroup;
children = (
8373BBB11A3740B3009E0297 /* NSDate+TimeAgo.h */,
8373BBB21A3740B3009E0297 /* NSDate+TimeAgo.m */,
8373BBB31A3740B3009E0297 /* NSDateTimeAgo.bundle */,
);
path = timeago;
sourceTree = "<group>";
};
83AE7D2D19FF1A9500DD152B /* simulator */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -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 */,
Expand All @@ -556,6 +585,7 @@
buildActionMask = 2147483647;
files = (
C1CEFE801463779D00466EB3 /* InfoPlist.strings in Resources */,
8373BBB81A3740B3009E0297 /* NSDateTimeAgo.bundle in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -564,6 +594,7 @@
buildActionMask = 2147483647;
files = (
C1CEFE991463779D00466EB3 /* InfoPlist.strings in Resources */,
8373BBB91A3740B3009E0297 /* NSDateTimeAgo.bundle in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -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 */,
Expand All @@ -648,6 +680,7 @@
buildActionMask = 2147483647;
files = (
C1CEFE831463779D00466EB3 /* CoreDataUtilTests.m in Sources */,
8373BBB51A3740B3009E0297 /* NSDate+TimeAgo.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -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;
};
Expand Down
8 changes: 7 additions & 1 deletion CoreDataUtil/MFLMainWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions CoreDataUtil/MFLMainWindowController.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14B25" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MFLMainWindowController">
Expand Down Expand Up @@ -165,7 +165,7 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="LINK" wantsLayer="YES" id="30" userLabel="MFLButtonTableViewCell" customClass="MFLTextTableCellView">
<rect key="frame" x="1" y="1" width="125.5" height="24"/>
<rect key="frame" x="1" y="1" width="126" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button id="33">
Expand Down Expand Up @@ -197,7 +197,7 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="TEXT" wantsLayer="YES" id="36" userLabel="MFLTextTableViewCell" customClass="MFLTextTableCellView">
<rect key="frame" x="130" y="1" width="97.5" height="24"/>
<rect key="frame" x="130" y="1" width="98" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<connections>
<outlet property="cellButton" destination="33" id="aGb-lk-PwL"/>
Expand Down Expand Up @@ -299,14 +299,14 @@
<size key="minSize" width="104" height="25"/>
<size key="maxSize" width="221" height="28"/>
<segmentedControl key="view" verticalHuggingPriority="750" id="142">
<rect key="frame" x="0.0" y="14" width="215" height="25"/>
<rect key="frame" x="1" y="14" width="214" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<segmentedCell key="cell" borderStyle="border" alignment="left" style="texturedSquare" trackingMode="selectOne" id="143">
<font key="font" metaFont="system"/>
<segments>
<segment label="Short" toolTip="1/15/86 3:30pm" width="55"/>
<segment label="Medium" toolTip="Medium: Jan 15, 1986" width="57" selected="YES" tag="1"/>
<segment label="Long" toolTip="Long: January 15, 1986 3:30:32pm" width="55"/>
<segment label="Fuzzy" toolTip="1/15/86 3:30pm" width="55"/>
<segment label="Short" toolTip="Medium: Jan 15, 1986" width="57" selected="YES" tag="1"/>
<segment label="Medium" toolTip="Long: January 15, 1986 3:30:32pm" width="55"/>
<segment label="Full" toolTip="Full: Wednesday, January 15, 1986 AD 3:30:32pm CST"/>
</segments>
</segmentedCell>
Expand Down
21 changes: 21 additions & 0 deletions CoreDataUtil/Utils/extensions/timeago/NSDate+TimeAgo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#import <Foundation/Foundation.h>

@interface NSDate (TimeAgo)
- (NSString *) timeAgoSimple;
- (NSString *) timeAgo;
- (NSString *) timeAgoWithLimit:(NSTimeInterval)limit;
- (NSString *) timeAgoWithLimit:(NSTimeInterval)limit dateFormat:(NSDateFormatterStyle)dFormatter andTimeFormat:(NSDateFormatterStyle)tFormatter;
- (NSString *) timeAgoWithLimit:(NSTimeInterval)limit dateFormatter:(NSDateFormatter *)formatter;


// this method only returns "{value} {unit} ago" strings and no "yesterday"/"last month" strings
- (NSString *)dateTimeAgo;

// this method gives when possible the date compared to the current calendar date: "this morning"/"yesterday"/"last week"/..
// when more precision is needed (= less than 6 hours ago) it returns the same output as dateTimeAgo
- (NSString *)dateTimeUntilNow;

@end



Loading

0 comments on commit 7c8a209

Please sign in to comment.