Просмотр исходного кода

fix #205 Imprv: Replace moment with date-fns

Yuki Takei 8 лет назад
Родитель
Сommit
790f45a04c

+ 0 - 3
config/webpack.common.js

@@ -102,9 +102,6 @@ module.exports = function (options) {
         hljs: "reveal.js/plugin/highlight/highlight",
         hljs: "reveal.js/plugin/highlight/highlight",
       }),
       }),
 
 
-      // omit moment/locale/*.js
-      new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /ja/),
-
     ]
     ]
   };
   };
 }
 }

+ 1 - 1
package.json

@@ -68,6 +68,7 @@
     "crowi-pluginkit": "^1.1.0",
     "crowi-pluginkit": "^1.1.0",
     "csrf": "~3.0.3",
     "csrf": "~3.0.3",
     "css-loader": "^0.28.0",
     "css-loader": "^0.28.0",
+    "date-fns": "^1.29.0",
     "debug": "^3.1.0",
     "debug": "^3.1.0",
     "diff": "^3.3.0",
     "diff": "^3.3.0",
     "diff2html": "^2.3.0",
     "diff2html": "^2.3.0",
@@ -93,7 +94,6 @@
     "md5": "^2.2.1",
     "md5": "^2.2.1",
     "method-override": "^2.3.10",
     "method-override": "^2.3.10",
     "mkdirp": "~0.5.1",
     "mkdirp": "~0.5.1",
-    "moment": "^2.19.3",
     "mongoose": "^4.13.5",
     "mongoose": "^4.13.5",
     "mongoose-paginate": "5.0.x",
     "mongoose-paginate": "5.0.x",
     "mongoose-unique-validator": "^1.0.6",
     "mongoose-unique-validator": "^1.0.6",

+ 2 - 2
resource/js/components/Common/UserDate.js

@@ -1,7 +1,7 @@
 import React from 'react';
 import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 
 
-import moment from 'moment';
+import dateFnsFormat from 'date-fns/format';
 
 
 /**
 /**
  * UserDate
  * UserDate
@@ -11,7 +11,7 @@ import moment from 'moment';
 export default class UserDate extends React.Component {
 export default class UserDate extends React.Component {
 
 
   render() {
   render() {
-    const dt = moment(this.props.dateTime).format(this.props.format);
+    const dt = dateFnsFormat(this.props.dateTime, this.props.format);
 
 
     return (
     return (
       <span className={this.props.className}>
       <span className={this.props.className}>

+ 2 - 2
resource/js/components/PageComment/Comment.js

@@ -1,7 +1,7 @@
 import React from 'react';
 import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 
 
-import moment from 'moment';
+import dateFnsFormat from 'date-fns/format';
 
 
 import ReactUtils from '../ReactUtils';
 import ReactUtils from '../ReactUtils';
 import UserPicture from '../User/UserPicture';
 import UserPicture from '../User/UserPicture';
@@ -53,7 +53,7 @@ export default class Comment extends React.Component {
     const creator = comment.creator;
     const creator = comment.creator;
 
 
     const rootClassName = this.getRootClassName();
     const rootClassName = this.getRootClassName();
-    const commentDate = moment(comment.createdAt).format('YYYY/MM/DD HH:mm');
+    const commentDate = dateFnsFormat(comment.createdAt, 'YYYY/MM/DD HH:mm');
     const commentBody = ReactUtils.nl2br(comment.comment);
     const commentBody = ReactUtils.nl2br(comment.comment);
     const creatorsPage = `/user/${creator.username}`;
     const creatorsPage = `/user/${creator.username}`;
     const revHref = `?revision=${comment.revision}`;
     const revHref = `?revision=${comment.revision}`;

+ 2 - 2
resource/js/components/PageComment/DeleteCommentModal.js

@@ -2,7 +2,7 @@ import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 
 
 import { Button, Modal } from 'react-bootstrap';
 import { Button, Modal } from 'react-bootstrap';
-import moment from 'moment';
+import dateFnsFormat from 'date-fns/format';
 
 
 import ReactUtils from '../ReactUtils';
 import ReactUtils from '../ReactUtils';
 import UserPicture from '../User/UserPicture';
 import UserPicture from '../User/UserPicture';
@@ -27,7 +27,7 @@ export default class DeleteCommentModal extends React.Component {
     }
     }
 
 
     const comment = this.props.comment;
     const comment = this.props.comment;
-    const commentDate = moment(comment.createdAt).format('YYYY/MM/DD HH:mm');
+    const commentDate = dateFnsFormat(comment.createdAt, 'YYYY/MM/DD HH:mm');
 
 
     // generate body
     // generate body
     let commentBody = comment.comment;
     let commentBody = comment.comment;

+ 0 - 1
resource/js/components/SearchPage/DeletePageListModal.js

@@ -2,7 +2,6 @@ import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 
 
 import { Button, Modal, Checkbox } from 'react-bootstrap';
 import { Button, Modal, Checkbox } from 'react-bootstrap';
-import moment from 'moment';
 
 
 import ReactUtils from '../ReactUtils';
 import ReactUtils from '../ReactUtils';
 
 

+ 4 - 4
resource/js/util/LangProcessor/Template.js

@@ -1,4 +1,4 @@
-import moment from 'moment';
+import dateFnsFormat from 'date-fns/format';
 
 
 export default class Template {
 export default class Template {
 
 
@@ -12,15 +12,15 @@ export default class Template {
   }
   }
 
 
   getYear() {
   getYear() {
-    return moment().format('YYYY');
+    return dateFnsFormat(new Date(), 'YYYY');
   }
   }
 
 
   getMonth() {
   getMonth() {
-    return moment().format('YYYY/MM');
+    return dateFnsFormat(new Date(), 'YYYY/MM');
   }
   }
 
 
   getDate() {
   getDate() {
-    return moment().format('YYYY/MM/DD');
+    return dateFnsFormat(new Date(), 'YYYY/MM/DD');
   }
   }
 
 
   getUser() {
   getUser() {

+ 4 - 4
yarn.lock

@@ -1704,6 +1704,10 @@ dashdash@^1.12.0:
   dependencies:
   dependencies:
     assert-plus "^1.0.0"
     assert-plus "^1.0.0"
 
 
+date-fns@^1.29.0:
+  version "1.29.0"
+  resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.29.0.tgz#12e609cdcb935127311d04d33334e2960a2a54e6"
+
 date-now@^0.1.4:
 date-now@^0.1.4:
   version "0.1.4"
   version "0.1.4"
   resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"
   resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"
@@ -3693,10 +3697,6 @@ mocha@^4.0.0:
     mkdirp "0.5.1"
     mkdirp "0.5.1"
     supports-color "4.4.0"
     supports-color "4.4.0"
 
 
-moment@^2.19.3:
-  version "2.19.3"
-  resolved "https://registry.yarnpkg.com/moment/-/moment-2.19.3.tgz#bdb99d270d6d7fda78cc0fbace855e27fe7da69f"
-
 mongodb-core@2.1.17:
 mongodb-core@2.1.17:
   version "2.1.17"
   version "2.1.17"
   resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-2.1.17.tgz#a418b337a14a14990fb510b923dee6a813173df8"
   resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-2.1.17.tgz#a418b337a14a14990fb510b923dee6a813173df8"