Bug 1356272 - Monthly archive folders should always have two-digit month to keep folders sorted. r=aceman
authorSebastian Hengst <archaeopteryx@coole-files.de>
Thu, 13 Apr 2017 17:57:54 +0200
changeset 28037 78522213bd3802ac01c80c0fa5c90a23a707505a
parent 28036 6bcade9daa96f10cdc7c356af6a781fa5930184e
child 28038 95da4e9ee8dc6cbf96b056b3e0e70ae90d0fff46
push id1966
push userclokep@gmail.com
push dateMon, 12 Jun 2017 16:57:35 +0000
treeherdercomm-beta@32d9b8d10da1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman
bugs1356272
Bug 1356272 - Monthly archive folders should always have two-digit month to keep folders sorted. r=aceman MozReview-Commit-ID: 11rkmMS3qFe
mail/base/content/mailWindowOverlay.js
mail/test/mozmill/folder-display/test-message-commands.js
--- a/mail/base/content/mailWindowOverlay.js
+++ b/mail/base/content/mailWindowOverlay.js
@@ -1674,17 +1674,17 @@ BatchMessageMover.prototype = {
       let msgHdr = aMsgHdrs[i];
 
       let server = msgHdr.folder.server;
       let rootFolder = server.rootFolder;
 
       // Convert date to JS date object.
       let msgDate = new Date(msgHdr.date / 1000);
       let msgYear = msgDate.getFullYear().toString();
-      let monthFolderName = msgYear + "-" + (msgDate.getMonth() + 1).toString();
+      let monthFolderName = msgYear + "-" + (msgDate.getMonth() + 1).toString().padStart(2, "0");
 
       let archiveFolderURI;
       let archiveGranularity;
       let archiveKeepFolderStructure;
 
       let identity = getIdentityForHeader(msgHdr);
       if (!identity) {
         // Some servers (RSS) don't have an identity, so we need to figure
--- a/mail/test/mozmill/folder-display/test-message-commands.js
+++ b/mail/test/mozmill/folder-display/test-message-commands.js
@@ -398,20 +398,20 @@ function monthly_archive(keep_structure)
   select_control_click_row(1);
 
   let firstMsgHdr = mc.folderDisplay.view.dbView.getMsgHdrAt(0);
   let lastMsgHdr = mc.folderDisplay.view.dbView.getMsgHdrAt(1);
   let firstMsgHdrMsgId = firstMsgHdr.messageId;
   let lastMsgHdrMsgId = lastMsgHdr.messageId;
   let firstMsgDate = new Date(firstMsgHdr.date / 1000);
   let firstMsgYear = firstMsgDate.getFullYear().toString();
-  let firstMonthFolderName = firstMsgYear + "-" + (firstMsgDate.getMonth() + 1).toString();
+  let firstMonthFolderName = firstMsgYear + "-" + (firstMsgDate.getMonth() + 1).toString().padStart(2, "0");
   let lastMsgDate = new Date(lastMsgHdr.date / 1000);
   let lastMsgYear = lastMsgDate.getFullYear().toString();
-  let lastMonthFolderName = lastMsgYear + "-" + (lastMsgDate.getMonth() + 1).toString();
+  let lastMonthFolderName = lastMsgYear + "-" + (lastMsgDate.getMonth() + 1).toString().padStart(2, "0");
 
   // Press the archive key. The results should go into two separate months.
   archive_selected_messages();
 
   // Figure out where the messages should have gone.
   let archiveRoot = "mailbox://nobody@Local%20Folders/Archives";
   let firstArchiveUri = archiveRoot + "/" + firstMsgYear +
                         "/" + firstMonthFolderName;