MCPcopy
hub / github.com/nilbuild/githunt / getTitle

Method getTitle

src/components/group-heading/index.js:8–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6
7class GroupHeading extends React.Component {
8 getTitle() {
9 const startMoment = moment(this.props.start);
10 const currentMoment = moment();
11 const yesterdayMoment = moment().subtract(1, 'day');
12
13 // For "day" jumps return the day name
14 if (this.props.dateJump === 'day') {
15 if (startMoment.isSame(currentMoment, 'day')) {
16 return 'Today';
17 } else if (startMoment.isSame(yesterdayMoment, 'day')) {
18 return 'Yesterday';
19 }
20
21 return startMoment.format('dddd');
22 }
23
24 // Return the relative date
25 const formattedDate = startMoment.fromNow();
26 if (formattedDate === 'a year ago') {
27 return 'Last year';
28 } else if (formattedDate === '7 days ago') {
29 return 'This week';
30 } else if (formattedDate === '14 days ago') {
31 return 'Last week';
32 }
33
34 return formattedDate;
35 }
36
37 getSubtitle() {
38 const startMoment = moment(this.props.start);

Callers 1

renderMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected