huridocs/uwazi

View on GitHub
app/react/Layout/PrintDate.js

Summary

Maintainability
A
0 mins
Test Coverage
import PropTypes from 'prop-types';
import React from 'react';
import moment from 'moment';

const PrintDate = ({ utc, toLocal }) => {
  let date;
  if (!toLocal) {
    date = moment.utc(utc).format('ll');
  }

  if (toLocal) {
    date = moment(moment(utc).toDate()).format('ll');
  }
  return <span>{date}</span>;
};

PrintDate.propTypes = {
  utc: PropTypes.number,
  toLocal: PropTypes.bool,
};

export default PrintDate;