diff --git a/src/VideoInfo.js b/src/VideoInfo.js index 021b9cb..64c9b9b 100644 --- a/src/VideoInfo.js +++ b/src/VideoInfo.js @@ -1,6 +1,6 @@ import React from 'react'; import Wikipedia from './areainfo/Wikipedia'; -import { Tabs, Tab, Table } from 'react-bootstrap'; +import { Tabs, Tab } from 'react-bootstrap'; import {Link, withRouter} from 'react-router-dom'; import axios from 'axios'; import Linkify from "react-linkify"; @@ -12,7 +12,6 @@ import './css/VideoInfo.scss'; const ytclear = require('@c0b41/ytclear'); - class VideoInfo extends React.Component { state = { @@ -25,7 +24,7 @@ class VideoInfo extends React.Component { }; momentDuration(duration) { - return moment.duration(duration).format('hh:mm:ss'); + return moment.duration(duration).format('hh:mm:ss') } ISO_8601parse(a) { @@ -144,8 +143,8 @@ class VideoInfo extends React.Component { render() { const { error, isLoaded, VideoDetails, comments } = this.state; - const momentDuration = this.momentDuration; // bind momentDuration in render to the actual method - const ISO_8601parse = this.ISO_8601parse; // bind momentDuration in render to the actual method + const momentDuration = this.momentDuration; + const ISO_8601parse = this.ISO_8601parse; if (error) { return ( @@ -203,6 +202,9 @@ class VideoInfo extends React.Component { ) })} + + /* Insert code here */ + {this.state.items.map(function (item,index) { @@ -60,9 +67,7 @@ class RecommenderRandom extends Component{ {item.snippet.title}
- {item.snippet.channelTitle} - {item.snippet.publishedAt.replace(/(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+).000Z/,function(match,p1,p2,p3,p4,p5,p6){ - return(p3+'/'+p2+'/'+p1+' at '+p4+':'+p5+':'+p6); //Funzione che trasforma la data e ora di pubblicazione dal formato ISO nel normale formato da cristiani - })} + {item.snippet.channelTitle} - {ISO_8601parse(item.snippet.publishedAt)}
diff --git a/src/reccomenders/Related.js b/src/reccomenders/Related.js index b1c3529..e816eb9 100644 --- a/src/reccomenders/Related.js +++ b/src/reccomenders/Related.js @@ -2,6 +2,8 @@ import React, { Component } from 'react'; import axios from 'axios'; import {Link} from "react-router-dom"; import {Card} from "react-bootstrap"; +import moment from "moment"; + class Related extends Component { constructor(props) { @@ -12,6 +14,9 @@ class Related extends Component { } } + ISO_8601parse(a) { + return moment(a, moment.ISO_8601).format('ddd, DD/MM/YYYY hh:mm:ss'); + } componentWillMount() { if(this.props.match.params.id){ if(this.props.match.params.id === this.state.videoId){} @@ -51,6 +56,7 @@ class Related extends Component { } render() { + const ISO_8601parse = this.ISO_8601parse; return (
{this.state.items.map(function (item,index) { @@ -70,9 +76,8 @@ class Related extends Component { {item.snippet.title}
- {item.snippet.channelTitle} - {item.snippet.publishedAt.replace(/(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+).000Z/,function(match,p1,p2,p3,p4,p5,p6){ - return(p3+'/'+p2+'/'+p1+' at '+p4+':'+p5+':'+p6); //Funzione che trasforma la data e ora di pubblicazione dal formato ISO nel normale formato da cristiani - })} + {item.snippet.channelTitle} - {ISO_8601parse(item.snippet.publishedAt)} +