File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,15 @@ function parseCommitter(line) {
22
22
return line . match ( committerMatcher ) [ 1 ] ;
23
23
}
24
24
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
+
25
34
/**
26
35
* Parses the commit date from blame data for a line of code.
27
36
*
@@ -32,8 +41,7 @@ function parseDate(line) {
32
41
var dateMatcher = / ^ c o m m i t t e r - t i m e \s ( .* ) $ / m;
33
42
var dateStamp = line . match ( dateMatcher ) [ 1 ] ;
34
43
35
- var formatString = atom . config . get ( 'git-blame.dateFormatString' ) ;
36
- return moment . unix ( dateStamp ) . format ( formatString ) ;
44
+ return formatDate ( moment . unix ( dateStamp ) ) ;
37
45
}
38
46
39
47
/**
@@ -103,5 +111,6 @@ function parseBlameOutput(blameOut) {
103
111
104
112
// EXPORTS
105
113
module . exports = {
106
- parseBlame : parseBlameOutput
114
+ parseBlame : parseBlameOutput ,
115
+ formatDate : formatDate
107
116
} ;
Original file line number Diff line number Diff line change 1
1
{$ , React , Reactionary } = require ' atom'
2
- RP = React .PropTypes
3
2
{div , span , a } = Reactionary
3
+ RP = React .PropTypes
4
+ moment = require ' moment'
5
+ {formatDate } = require ' ../util/blameFormatter'
4
6
5
7
HASH_LENGTH = 7 # github uses this length
6
8
BLANK_HASH = ' -' .repeat (HASH_LENGTH)
9
+ DEFAULT_DATE = formatDate moment (" 2000-01-01T13:17:00 Z" )
7
10
8
11
9
12
renderLoading = ->
10
13
div className : ' blame-line loading' ,
11
14
span className : ' hash' , BLANK_HASH
12
- span className : ' date' , ' 1337-01-01 '
15
+ span className : ' date' , DEFAULT_DATE
13
16
span className : ' committer' , ' Loading'
14
17
15
18
You can’t perform that action at this time.
0 commit comments