Skip to content

Commit

Permalink
Add a 24-hour-format export filename token.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrog committed Aug 7, 2017
1 parent e3f8970 commit 0164dba
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
1 change: 1 addition & 0 deletions Source/SPConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ extern NSString *SPFileNameYearTokenName;
extern NSString *SPFileNameMonthTokenName;
extern NSString *SPFileNameDayTokenName;
extern NSString *SPFileNameTimeTokenName;
extern NSString *SPFileName24HourTimeTokenName;
extern NSString *SPFileNameFavoriteTokenName;
extern NSString *SPFileNameTableTokenName;

Expand Down
19 changes: 10 additions & 9 deletions Source/SPConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,16 @@
NSString *SPLastExportSettings = @"LastExportSettings";

// Export filename tokens
NSString *SPFileNameDatabaseTokenName = @"database";
NSString *SPFileNameHostTokenName = @"host";
NSString *SPFileNameDateTokenName = @"date";
NSString *SPFileNameYearTokenName = @"year";
NSString *SPFileNameMonthTokenName = @"month";
NSString *SPFileNameDayTokenName = @"day";
NSString *SPFileNameTimeTokenName = @"time";
NSString *SPFileNameFavoriteTokenName = @"favorite";
NSString *SPFileNameTableTokenName = @"table";
NSString *SPFileNameDatabaseTokenName = @"database";
NSString *SPFileNameHostTokenName = @"host";
NSString *SPFileNameDateTokenName = @"date";
NSString *SPFileNameYearTokenName = @"year";
NSString *SPFileNameMonthTokenName = @"month";
NSString *SPFileNameDayTokenName = @"day";
NSString *SPFileNameTimeTokenName = @"time";
NSString *SPFileName24HourTimeTokenName = @"time24";
NSString *SPFileNameFavoriteTokenName = @"favorite";
NSString *SPFileNameTableTokenName = @"table";

// Misc
NSString *SPContentFilters = @"ContentFilters";
Expand Down
19 changes: 10 additions & 9 deletions Source/SPExportController.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,16 @@ - (id)init
prefs = [NSUserDefaults standardUserDefaults];

localizedTokenNames = [@{
SPFileNameHostTokenName: NSLocalizedString(@"Host", @"export filename host token"),
SPFileNameDatabaseTokenName: NSLocalizedString(@"Database", @"export filename database token"),
SPFileNameTableTokenName: NSLocalizedString(@"Table", @"table"),
SPFileNameDateTokenName: NSLocalizedString(@"Date", @"export filename date token"),
SPFileNameYearTokenName: NSLocalizedString(@"Year", @"export filename date token"),
SPFileNameMonthTokenName: NSLocalizedString(@"Month", @"export filename date token"),
SPFileNameDayTokenName: NSLocalizedString(@"Day", @"export filename date token"),
SPFileNameTimeTokenName: NSLocalizedString(@"Time", @"export filename time token"),
SPFileNameFavoriteTokenName: NSLocalizedString(@"Favorite", @"export filename favorite name token")
SPFileNameHostTokenName: NSLocalizedString(@"Host", @"export filename host token"),
SPFileNameDatabaseTokenName: NSLocalizedString(@"Database", @"export filename database token"),
SPFileNameTableTokenName: NSLocalizedString(@"Table", @"table"),
SPFileNameDateTokenName: NSLocalizedString(@"Date", @"export filename date token"),
SPFileNameYearTokenName: NSLocalizedString(@"Year", @"export filename date token"),
SPFileNameMonthTokenName: NSLocalizedString(@"Month", @"export filename date token"),
SPFileNameDayTokenName: NSLocalizedString(@"Day", @"export filename date token"),
SPFileNameTimeTokenName: NSLocalizedString(@"Time", @"export filename time token"),
SPFileName24HourTimeTokenName: NSLocalizedString(@"24-Hour Time", @"export filename time token"),
SPFileNameFavoriteTokenName: NSLocalizedString(@"Favorite", @"export filename favorite name token")
} retain];
}

Expand Down
4 changes: 4 additions & 0 deletions Source/SPExportFilenameUtilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ - (void)updateAvailableExportFilenameTokens
[SPExportFileNameTokenObject tokenWithId:SPFileNameMonthTokenName],
[SPExportFileNameTokenObject tokenWithId:SPFileNameDayTokenName],
[SPExportFileNameTokenObject tokenWithId:SPFileNameTimeTokenName],
[SPExportFileNameTokenObject tokenWithId:SPFileName24HourTimeTokenName],
[SPExportFileNameTokenObject tokenWithId:SPFileNameFavoriteTokenName],
(tableObject = [SPExportFileNameTokenObject tokenWithId:SPFileNameTableTokenName]),
nil
Expand Down Expand Up @@ -296,6 +297,9 @@ - (NSString *)expandCustomFilenameFormatUsingTableName:(NSString *)table
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
[string appendString:[dateFormatter stringFromDate:[NSDate date]]];
}
else if ([tokenContent isEqualToString:SPFileName24HourTimeTokenName]) {
[string appendString:[[NSDate date] descriptionWithCalendarFormat:@"%H:%M:%S" timeZone:nil locale:nil]];
}
else if ([tokenContent isEqualToString:SPFileNameFavoriteTokenName]) {
[string appendStringOrNil:[tableDocumentInstance name]];
}
Expand Down

0 comments on commit 0164dba

Please sign in to comment.