From c6f6bb398dfa860c8eb2fb6c56bad4c54422b8b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Tue, 3 Nov 2015 10:57:41 +0100 Subject: [PATCH] Replace all occurrences of with momentjs --- README.md | 1 + .../ascribe_accordion_list/accordion_list_item_wallet.js | 3 ++- js/components/ascribe_detail/edition.js | 3 ++- js/components/ascribe_detail/piece_container.js | 3 ++- .../ascribe_accordion_list/accordion_list_item_prize.js | 3 ++- .../prize/components/ascribe_detail/prize_piece_container.js | 2 +- .../components/ascribe_detail/wallet_piece_container.js | 3 ++- .../cyland_accordion_list/cyland_accordion_list_item.js | 3 ++- .../ikonotv_accordion_list/ikonotv_accordion_list_item.js | 3 ++- js/utils/file_utils.js | 5 +++-- 10 files changed, 19 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 1dc4492b..a359657b 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ For this project, we're using: * We don't use ES6's class declaration for React components because it does not support Mixins as well as Autobinding ([Blog post about it](http://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#autobinding)) * We don't use camel case for file naming but in everything Javascript related * We use `let` instead of `var`: [SA Post](http://stackoverflow.com/questions/762011/javascript-let-keyword-vs-var-keyword) +* We don't use Javascript's `Date` object, as its interface introduced bugs previously and we're including `momentjs` for other dependencies anyways SCSS Code Conventions diff --git a/js/components/ascribe_accordion_list/accordion_list_item_wallet.js b/js/components/ascribe_accordion_list/accordion_list_item_wallet.js index 8899c67e..da45d1e8 100644 --- a/js/components/ascribe_accordion_list/accordion_list_item_wallet.js +++ b/js/components/ascribe_accordion_list/accordion_list_item_wallet.js @@ -1,6 +1,7 @@ 'use strict'; import React from 'react'; +import Moment from 'moment'; import Glyphicon from 'react-bootstrap/lib/Glyphicon'; import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger'; @@ -129,7 +130,7 @@ let AccordionListItemWallet = React.createClass({ piece={this.props.content} subsubheading={
- {new Date(this.props.content.date_created).getUTCFullYear()} + {Moment(this.props.content.date_created, 'YYYY-MM-DD').year()} {this.getLicences()}
} buttons={ diff --git a/js/components/ascribe_detail/edition.js b/js/components/ascribe_detail/edition.js index ae53728f..6b38ddf8 100644 --- a/js/components/ascribe_detail/edition.js +++ b/js/components/ascribe_detail/edition.js @@ -2,6 +2,7 @@ import React from 'react'; import { Link, History } from 'react-router'; +import Moment from 'moment'; import Row from 'react-bootstrap/lib/Row'; import Col from 'react-bootstrap/lib/Col'; @@ -85,7 +86,7 @@ let Edition = React.createClass({

{this.props.edition.title}

- +

{this.state.piece.title}

- + {this.state.piece.num_editions > 0 ? : null}
diff --git a/js/components/whitelabel/prize/components/ascribe_accordion_list/accordion_list_item_prize.js b/js/components/whitelabel/prize/components/ascribe_accordion_list/accordion_list_item_prize.js index 8eac81d1..08ebce42 100644 --- a/js/components/whitelabel/prize/components/ascribe_accordion_list/accordion_list_item_prize.js +++ b/js/components/whitelabel/prize/components/ascribe_accordion_list/accordion_list_item_prize.js @@ -3,6 +3,7 @@ import React from 'react'; import { Link } from 'react-router'; import StarRating from 'react-star-rating'; +import Moment from 'moment'; import PieceListActions from '../../../../../actions/piece_list_actions'; import PieceListStore from '../../../../../stores/piece_list_store'; @@ -182,7 +183,7 @@ let AccordionListItemPrize = React.createClass({ artistName={artistName} subsubheading={
- {new Date(this.props.content.date_created).getUTCFullYear()} + {Moment(this.props.content.date_created, 'YYYY-MM-DD').year()}
} buttons={this.getPrizeButtons()} badge={this.getPrizeBadge()}> diff --git a/js/components/whitelabel/prize/components/ascribe_detail/prize_piece_container.js b/js/components/whitelabel/prize/components/ascribe_detail/prize_piece_container.js index 6bd47c18..e2de24df 100644 --- a/js/components/whitelabel/prize/components/ascribe_detail/prize_piece_container.js +++ b/js/components/whitelabel/prize/components/ascribe_detail/prize_piece_container.js @@ -141,7 +141,7 @@ let PieceContainer = React.createClass({

{this.state.piece.title}

- + {artistEmail} {this.getActions()}
diff --git a/js/components/whitelabel/wallet/components/ascribe_detail/wallet_piece_container.js b/js/components/whitelabel/wallet/components/ascribe_detail/wallet_piece_container.js index e765bd7b..b263e517 100644 --- a/js/components/whitelabel/wallet/components/ascribe_detail/wallet_piece_container.js +++ b/js/components/whitelabel/wallet/components/ascribe_detail/wallet_piece_container.js @@ -1,6 +1,7 @@ 'use strict'; import React from 'react'; +import Moment from 'moment'; import Piece from '../../../../../components/ascribe_detail/piece'; @@ -39,7 +40,7 @@ let WalletPieceContainer = React.createClass({

{this.props.piece.title}

- +
} diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_accordion_list/cyland_accordion_list_item.js b/js/components/whitelabel/wallet/components/cyland/cyland_accordion_list/cyland_accordion_list_item.js index 0b4ec543..9802e93e 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_accordion_list/cyland_accordion_list_item.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_accordion_list/cyland_accordion_list_item.js @@ -1,6 +1,7 @@ 'use strict'; import React from 'react'; +import Moment from 'moment'; import AccordionListItemPiece from '../../../../../ascribe_accordion_list/accordion_list_item_piece'; @@ -100,7 +101,7 @@ let CylandAccordionListItem = React.createClass({ piece={this.props.content} subsubheading={
- {new Date(this.props.content.date_created).getUTCFullYear()} + {Moment(this.props.content.date_created, 'YYYY-MM-DD').year()}
} buttons={this.getSubmitButtons()}> {this.props.children} diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_accordion_list/ikonotv_accordion_list_item.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_accordion_list/ikonotv_accordion_list_item.js index e1187b7c..f2f73767 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_accordion_list/ikonotv_accordion_list_item.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_accordion_list/ikonotv_accordion_list_item.js @@ -1,6 +1,7 @@ 'use strict'; import React from 'react'; +import Moment from 'moment'; import AccordionListItemPiece from '../../../../../ascribe_accordion_list/accordion_list_item_piece'; @@ -106,7 +107,7 @@ let IkonotvAccordionListItem = React.createClass({ piece={this.props.content} subsubheading={
- {new Date(this.props.content.date_created).getUTCFullYear()} + {Moment(this.props.content.date_created, 'YYYY-MM-DD').year()}
} buttons={this.getSubmitButtons()}> {this.props.children} diff --git a/js/utils/file_utils.js b/js/utils/file_utils.js index 964ba7b8..3454404a 100644 --- a/js/utils/file_utils.js +++ b/js/utils/file_utils.js @@ -2,6 +2,7 @@ import Q from 'q'; import SparkMD5 from 'spark-md5'; +import Moment from 'moment'; import { getLangText } from './lang_utils'; @@ -37,7 +38,7 @@ export function computeHashOfFile(file) { let spark = new SparkMD5.ArrayBuffer(); let fileReader = new FileReader(); - let startTime = new Date(); + let startTime = new Moment(); // comment: We should convert this to es6 at some point, however if so please consider that // an arrow function will get rid of the function's scope... @@ -53,7 +54,7 @@ export function computeHashOfFile(file) { console.info('computed hash %s (took %d s)', fileHash, - Math.round(((new Date() - startTime) / 1000) % 60)); // Compute hash + Math.round(((new Moment() - startTime) / 1000) % 60)); // Compute hash let blobTextFile = makeTextFile(fileHash, file); resolve(blobTextFile);