Skip to content

Commit 90bef04

Browse files
committed
Merge pull request #32 from dmnd/loading-polish
Make loading date value formatted consistent with user preference
2 parents 016765c + 39133b1 commit 90bef04

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

lib/util/blameFormatter.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ function parseCommitter(line) {
2222
return line.match(committerMatcher)[1];
2323
}
2424

25+
/**
26+
* Formats a date according to the user's preferred format string.
27+
* @param {object} date - a moment date object
28+
*/
29+
function formatDate(date) {
30+
var formatString = atom.config.get('git-blame.dateFormatString');
31+
return date.format(formatString);
32+
}
33+
2534
/**
2635
* Parses the commit date from blame data for a line of code.
2736
*
@@ -32,8 +41,7 @@ function parseDate(line) {
3241
var dateMatcher = /^committer-time\s(.*)$/m;
3342
var dateStamp = line.match(dateMatcher)[1];
3443

35-
var formatString = atom.config.get('git-blame.dateFormatString');
36-
return moment.unix(dateStamp).format(formatString);
44+
return formatDate(moment.unix(dateStamp));
3745
}
3846

3947
/**
@@ -103,5 +111,6 @@ function parseBlameOutput(blameOut) {
103111

104112
// EXPORTS
105113
module.exports = {
106-
parseBlame: parseBlameOutput
114+
parseBlame: parseBlameOutput,
115+
formatDate: formatDate
107116
};

lib/views/blame-line-view.coffee

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
{$, React, Reactionary} = require 'atom'
2-
RP = React.PropTypes
32
{div, span, a} = Reactionary
3+
RP = React.PropTypes
4+
moment = require 'moment'
5+
{formatDate} = require '../util/blameFormatter'
46

57
HASH_LENGTH = 7 # github uses this length
68
BLANK_HASH = '-'.repeat(HASH_LENGTH)
9+
DEFAULT_DATE = formatDate moment("2000-01-01T13:17:00 Z")
710

811

912
renderLoading = ->
1013
div className: 'blame-line loading',
1114
span className: 'hash', BLANK_HASH
12-
span className: 'date', '1337-01-01'
15+
span className: 'date', DEFAULT_DATE
1316
span className: 'committer', 'Loading'
1417

1518

0 commit comments

Comments
 (0)