Skip to content

Commit

Permalink
Merge pull request #2315 from metabase/fix-default-time-formatting
Browse files Browse the repository at this point in the history
Fix default time formatting + column header
  • Loading branch information
agilliland committed Apr 5, 2016
2 parents 1b19a33 + c45db96 commit ba7fba0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion frontend/src/lib/formatting.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ function formatMajorMinor(major, minor, options = {}) {

function formatTimeWithUnit(value, unit, options = {}) {
let m = parseTimestamp(value);
if (!m.isValid()) {
return String(value);
}
switch (unit) {
case "hour": // 12 AM - January 1, 2015
return formatMajorMinor(m.format("h A"), m.format("MMMM D, YYYY"), options);
Expand All @@ -75,8 +78,9 @@ function formatTimeWithUnit(value, unit, options = {}) {
return moment().week(value).format("wo");
case "month-of-year": // January
return moment().month(value - 1).format("MMMM");
default:
return m.format("LLLL");
}
return String(value);
}

export function formatValue(value, options = {}) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/visualizations/TableInteractive.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export default class TableInteractive extends Component {
colVal = (column && column.display_name && column.display_name.toString()) ||
(column && column.name && column.name.toString());

if (column.unit) {
if (column.unit && column.unit !== "default") {
colVal += ": " + capitalize(column.unit.replace(/-/g, " "))
}

Expand Down

0 comments on commit ba7fba0

Please sign in to comment.