Permalink
Browse files

Merge pull request #2852 from michaelrog/feature/24-hour-date-token

Add a 24-hour-format time token(s) for the custom export filename field
  • Loading branch information...
abhibeckert committed Aug 8, 2017
2 parents e3f8970 + 0164dba commit 0625044f52367c2e5778c326f6ca3f4fe3bdcc78
Showing with 25 additions and 18 deletions.
  1. +1 −0 Source/SPConstants.h
  2. +10 −9 Source/SPConstants.m
  3. +10 −9 Source/SPExportController.m
  4. +4 −0 Source/SPExportFilenameUtilities.m
View
@@ -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;
View
@@ -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";
@@ -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];
}
@@ -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
@@ -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]];
}

0 comments on commit 0625044

Please sign in to comment.