Skip to content

Commit

Permalink
Fixes #182
Browse files Browse the repository at this point in the history
The "uptime" command will now stop reporting at days. Weeks, months, and years are no longer included in the count.
  • Loading branch information
emsquared committed Jun 5, 2012
1 parent d14b208 commit 8e5d295
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Classes/Dialogs/HighlightSheet.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ - (id)tableView:(NSTableView *)sender objectValueForTableColumn:(NSTableColumn *
} else if ([col isEqualToString:@"time"]) {
NSInteger time = [item integerAtIndex:1];

return TXTFLS(@"TIME_AGO", TXSpecialReadableTime([NSDate secondsSinceUnixTimestamp:time], YES));
return TXTFLS(@"TIME_AGO", TXSpecialReadableTime([NSDate secondsSinceUnixTimestamp:time], YES, nil));
} else {
return [item safeObjectAtIndex:2];
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Headers/GlobalModels.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ TEXTUAL_EXTERN NSString *TXFormattedTimestamp(NSDate *date, NSString *format);
TEXTUAL_EXTERN NSString *TXFormattedTimestampWithOverride(NSDate *date, NSString *format, NSString *override);

TEXTUAL_EXTERN NSString *TXReadableTime(NSInteger dateInterval);
TEXTUAL_EXTERN NSString *TXSpecialReadableTime(NSInteger dateInterval, BOOL shortValue);
TEXTUAL_EXTERN NSString *TXSpecialReadableTime(NSInteger dateInterval, BOOL shortValue, NSArray *orderMatrix);

TEXTUAL_EXTERN NSString *TXFormattedNumber(NSInteger number);
2 changes: 1 addition & 1 deletion Classes/Headers/IRCColorFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ typedef enum {
IRCTextFormatterBackgroundColorEffect,
} IRCTextFormatterEffectType;

#define MAXIMUM_FORMATTING_LENGTH 600
#define MAXIMUM_FORMATTING_LENGTH 300

@interface NSAttributedString (IRCTextFormatter)
- (NSString *)attributedStringToASCIIFormatting;
Expand Down
8 changes: 5 additions & 3 deletions Classes/Library/GlobalModels.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ void DevNullDestroyObject(BOOL condition, ...)
return TXFormattedTimestampWithOverride(date, format, nil);
}

NSString *TXSpecialReadableTime(NSInteger dateInterval, BOOL shortValue)
NSString *TXSpecialReadableTime(NSInteger dateInterval, BOOL shortValue, NSArray *orderMatrix)
{
NSArray *orderMatrix = [NSArray arrayWithObjects:@"year", @"month", @"week", @"day", @"hour", @"minute", @"second", nil];
if (NSObjectIsEmpty(orderMatrix)) {
orderMatrix = [NSArray arrayWithObjects:@"year", @"month", @"week", @"day", @"hour", @"minute", @"second", nil];
}

NSCalendar *sysCalendar = [NSCalendar currentCalendar];

Expand Down Expand Up @@ -110,7 +112,7 @@ void DevNullDestroyObject(BOOL condition, ...)

NSString *TXReadableTime(NSInteger dateInterval)
{
return TXSpecialReadableTime(dateInterval, NO);
return TXSpecialReadableTime(dateInterval, NO, nil);
}

NSInteger TXRandomNumber(NSInteger maxset)
Expand Down
4 changes: 4 additions & 0 deletions Main Project (Textual).xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
4CB91A4113680BB9005E00E8 /* ServerList.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CB91A3F13680BB9005E00E8 /* ServerList.m */; };
4CB91A4513680C4B005E00E8 /* NSOutlineViewHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CB91A4413680C4B005E00E8 /* NSOutlineViewHelper.m */; };
4CCB939913689A1B00085C3E /* ServerListCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CCB939813689A1B00085C3E /* ServerListCell.m */; };
4CCFEDBE157DABF600A8DE6A /* adventure-cat.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 4CCFEDBD157DABF600A8DE6A /* adventure-cat.jpg */; };
4CD3CA46138B9768002FD1E3 /* ChannelCellSelection_Aqua.tif in Resources */ = {isa = PBXBuildFile; fileRef = 4CD3CA42138B9768002FD1E3 /* ChannelCellSelection_Aqua.tif */; };
4CD3CA47138B9768002FD1E3 /* ChannelCellSelection_Graphite.tif in Resources */ = {isa = PBXBuildFile; fileRef = 4CD3CA43138B9768002FD1E3 /* ChannelCellSelection_Graphite.tif */; };
4CD3CA48138B9768002FD1E3 /* ServerCellSelection_Graphite.tif in Resources */ = {isa = PBXBuildFile; fileRef = 4CD3CA44138B9768002FD1E3 /* ServerCellSelection_Graphite.tif */; };
Expand Down Expand Up @@ -570,6 +571,7 @@
4CCB9392136899E500085C3E /* ServerListCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ServerListCell.h; path = Classes/Headers/ServerListCell.h; sourceTree = SOURCE_ROOT; };
4CCB939813689A1B00085C3E /* ServerListCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ServerListCell.m; path = ../ServerListCell.m; sourceTree = "<group>"; };
4CCD0F8711BAE7E900758B81 /* GlobalModels.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GlobalModels.m; sourceTree = "<group>"; };
4CCFEDBD157DABF600A8DE6A /* adventure-cat.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "adventure-cat.jpg"; sourceTree = "<group>"; };
4CD0136C12F0C772001953E6 /* IRCModeInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IRCModeInfo.m; sourceTree = "<group>"; };
4CD0E5E912F1B45900C8F016 /* GrowlController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GrowlController.h; path = Classes/Headers/GrowlController.h; sourceTree = SOURCE_ROOT; };
4CD0E5EA12F1B45900C8F016 /* MasterController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MasterController.h; path = Classes/Headers/MasterController.h; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -1029,6 +1031,7 @@
4C5AEF2312D1B6E400D6B18C /* Application */ = {
isa = PBXGroup;
children = (
4CCFEDBD157DABF600A8DE6A /* adventure-cat.jpg */,
4C5AEF2412D1B6E400D6B18C /* application.icns */,
);
path = Application;
Expand Down Expand Up @@ -1855,6 +1858,7 @@
4CD3CA49138B9768002FD1E3 /* ServerCellSelection_Aqua.tif in Resources */,
4CFB1055138CE8E0007B8F2E /* HighlightSheet.xib in Resources */,
4C73E9AB1578164100992CD1 /* Scripts in Resources */,
4CCFEDBE157DABF600A8DE6A /* adventure-cat.jpg in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file added Resources/Images/Application/adventure-cat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Resources/Miscellaneous/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<plist version="1.0">
<dict>
<key>Build Number</key>
<string>10056</string>
<string>10063</string>
<key>Build Reference</key>
<string>2.1.1-83-g332f1aa-debug</string>
<string>2.1.1-84-gd14b208-stdbuild</string>
<key>CFBundleExecutable</key>
<string>Textual</string>
<key>CFBundleIconFile</key>
Expand Down
21 changes: 18 additions & 3 deletions Resources/Plugins/SystemProfiler/TPI_SP_SysInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#define LOCAL_VOLUME_DICTIONARY @"/Volumes"
#define MEMORY_DIVISION_SIZE 1.073741824

@interface TPI_SP_SysInfo (Private)
+ (NSInteger)_internalSystemUptime;
@end

@implementation TPI_SP_SysInfo

#pragma mark -
Expand Down Expand Up @@ -126,7 +130,13 @@ + (NSString *)getAllScreenResolutions

+ (NSString *)applicationAndSystemUptime
{
return [NSString stringWithFormat:@"System Uptime: %@ - Textual Uptime: %@", [self systemUptime], TXReadableTime([NSDate secondsSinceUnixTimestamp:[Preferences startTime]])];
NSString *systemUptime = TXSpecialReadableTime([self _internalSystemUptime], NO,
[NSArray arrayWithObjects:@"day", @"hour", @"minute", @"second", nil]);

NSString *textualUptime = TXSpecialReadableTime([NSDate secondsSinceUnixTimestamp:[Preferences startTime]], NO,
[NSArray arrayWithObjects:@"day", @"hour", @"minute", @"second", nil]);

return [NSString stringWithFormat:@"System Uptime: %@ - Textual Uptime: %@", systemUptime, textualUptime];
}

+ (NSString *)getCurrentThemeInUse:(IRCWorld *)world
Expand Down Expand Up @@ -410,7 +420,7 @@ + (NSString *)diskInfo
}
}

+ (NSString *)systemUptimeUsingShortValue:(BOOL)shortValue
+ (NSInteger)_internalSystemUptime
{
struct timeval boottime;
size_t size = sizeof(boottime);
Expand All @@ -419,7 +429,12 @@ + (NSString *)systemUptimeUsingShortValue:(BOOL)shortValue
boottime.tv_sec = 0;
}

return TXSpecialReadableTime([NSDate secondsSinceUnixTimestamp:boottime.tv_sec], shortValue);
return [NSDate secondsSinceUnixTimestamp:boottime.tv_sec];
}

+ (NSString *)systemUptimeUsingShortValue:(BOOL)shortValue
{
return TXSpecialReadableTime([self _internalSystemUptime], shortValue, nil);
}

+ (NSString *)systemUptime
Expand Down

0 comments on commit 8e5d295

Please sign in to comment.