itizawa 5 лет назад
Родитель
Сommit
eb5da9b19b
2 измененных файлов с 4 добавлено и 17 удалено
  1. 4 3
      src/client/js/components/Navbar/AuthorInfo.jsx
  2. 0 14
      src/lib/util/date-utils.js

+ 4 - 3
src/client/js/components/Navbar/AuthorInfo.jsx

@@ -1,10 +1,11 @@
 import React from 'react';
 import PropTypes from 'prop-types';
 import { userPageRoot } from '@commons/util/path-utils';
-import { formatDateToDisplay } from '../../../../lib/util/date-utils';
+import { format } from 'date-fns';
 
 import UserPicture from '../User/UserPicture';
 
+const formatType = 'yyyy/MM/dd HH:mm';
 const AuthorInfo = (props) => {
   const {
     mode, user, date, locate,
@@ -21,7 +22,7 @@ const AuthorInfo = (props) => {
     : <i>Unknown</i>;
 
   if (locate === 'footer') {
-    return <p>{infoLabelForFooter} {formatDateToDisplay(date)} by <UserPicture user={user} size="sm" /> {userLabel}</p>;
+    return <p>{infoLabelForFooter} {format(new Date(date), formatType)} by <UserPicture user={user} size="sm" /> {userLabel}</p>;
   }
 
   return (
@@ -31,7 +32,7 @@ const AuthorInfo = (props) => {
       </div>
       <div>
         <div>{infoLabelForSubNav} {userLabel}</div>
-        <div className="text-muted text-date">{formatDateToDisplay(date)}</div>
+        <div className="text-muted text-date">{format(new Date(date), formatType)}</div>
       </div>
     </div>
   );

+ 0 - 14
src/lib/util/date-utils.js

@@ -1,14 +0,0 @@
-const { format } = require('date-fns');
-
-/**
- * Format any text
- * @param {*} date string
- * @param {*} formatType string
- */
-const formatDateToDisplay = (date, formatType = 'yyyy/MM/dd HH:mm') => {
-  return format(new Date(date), formatType);
-};
-
-module.exports = {
-  formatDateToDisplay,
-};