Browse Source

createFileNameFromAsset Add mask date DD MM YY

Marino Faggiana 8 years ago
parent
commit
7be07e2a7e
1 changed files with 22 additions and 2 deletions
  1. 22 2
      iOSClient/Utility/CCUtility.m

+ 22 - 2
iOSClient/Utility/CCUtility.m

@@ -495,13 +495,33 @@
     NSString *fileNameExt = [[assetFileName pathExtension] lowercaseString];
     
     if (key) {
+        
         fileName = [CCUtility getFileNameMask:key];
-        if ([fileName length] > 0)
+        
+        if ([fileName length] > 0) {
+            
+            [formatter setDateFormat:@"dd"];
+            NSString *day = [formatter stringFromDate:assetDate];
+            [formatter setDateFormat:@"MMM"];
+            NSString *month = [formatter stringFromDate:assetDate];
+            [formatter setDateFormat:@"yyyy"];
+            NSString *year = [formatter stringFromDate:assetDate];
+            
+            // Replace string with date
+
+            fileName = [fileName stringByReplacingOccurrencesOfString:@"DD" withString:day];
+            fileName = [fileName stringByReplacingOccurrencesOfString:@"MM" withString:month];
+            fileName = [fileName stringByReplacingOccurrencesOfString:@"YY" withString:year];
+
             fileName = [NSString stringWithFormat:@"%@-%@.%@", fileName, numberFileName, fileNameExt];
-        else
+            
+        } else {
+            
             fileName = [NSString stringWithFormat:@"%@ %@.%@", fileNameDate, numberFileName, fileNameExt];
+        }
         
     } else {
+        
         fileName = [NSString stringWithFormat:@"%@ %@.%@", fileNameDate, numberFileName, fileNameExt];
     }