Skip to content

Commit

Permalink
more places where negative dates matter
Browse files Browse the repository at this point in the history
  • Loading branch information
rneher committed Aug 15, 2018
1 parent 20a0211 commit 16c0650
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/info/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ const pluralise = (word, n) => {
};

const styliseDateRange = (dateStr) => {
// 2012-01-22
const fields = dateStr.split('-');
return `${months[fields[1]]} ${fields[0]}`;
// 2012-01-22
if (fields.length==3){
return `${months[fields[1]]} ${fields[0]}`;
}else{ // other cases like negative numbers
return dateStr;
}
};

const getNumSelectedTips = (nodes, visibility) => {
Expand Down
3 changes: 3 additions & 0 deletions src/util/dateHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const dateScale = scaleTime()
.range([2000, 2100]);

export const numericToCalendar = (numDate) => {
if (numDate<0){
return Math.round(numDate).toString();
}
const d3Date = dateScale.invert(numDate);
const calDate = dateFormatter(d3Date);
return calDate;
Expand Down

0 comments on commit 16c0650

Please sign in to comment.