Skip to content

Commit

Permalink
[view] use locale time and change revision format
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolab committed Dec 13, 2014
1 parent 9664dd1 commit 9141cf5
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/local-history-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,24 @@ LocalHistoryView.prototype.openDifftool = function openDifftool(current, revisio
};

LocalHistoryView.prototype.saveRevision = function saveRevision(buffer) {
var now, pathDirName, file;
var now, pathDirName, file, revFileName;

now = new Date();
pathDirName = path.dirname(buffer.file.path);

// YYYY-mm-dd_HH-ii-ss_basename
revFileName = now.getFullYear() +
'-' + (now.getMonth() + 1) +
'-' + now.getDate() +
'_' + now.toLocaleTimeString().replace(/:/g, '-') +
'_' + path.basename(buffer.file.path)
;

if(process.platform === 'win32') {
pathDirName = pathDirName.replace(/:/g,'');
}

file = path.join(
localHistoryPath,
pathDirName,

// YYYY-mm-dd.HH.ii.ss.basename
now.toISOString().replace(/^(\d{4}\-\d{2}\-\d{2}).(\d{2})\:(\d{2})\:(\d{2}).*$/,
'$1_$2.$3.$4.') + path.basename(buffer.file.path)
);
file = path.join(localHistoryPath, pathDirName, revFileName);

fsPlus.writeFile(file, buffer.cachedDiskContents, function(err) {
var messages;
Expand Down

0 comments on commit 9141cf5

Please sign in to comment.