Dater to handle year dates (ie YYYY) and display accordingly; Initial setup default value respected

This commit is contained in:
James Barnsley
2019-01-25 12:59:17 +13:00
parent f730ac3a0c
commit 8de22e43e4
10 changed files with 139 additions and 129 deletions

View File

@ -74,17 +74,22 @@ export default class Dater extends React.Component{
duration += parseInt(tracks[i].duration);
}
}
return this.durationSentence(duration)
break
return this.durationSentence(duration);
case 'length':
return this.durationTime(this.props.data)
break
return this.durationTime(this.props.data);
case 'date':
var date = new Date(this.props.data)
return date.getDate()+'/'+date.getMonth()+'/'+date.getFullYear()
break
// A four-character date indicates just a year (rather than a full date)
if (this.props.data.length == 4){
return this.props.data;
// Digest as a date string
} else {
var date = new Date(this.props.data);
return date.getDate()+'/'+(date.getMonth()+1)+'/'+date.getFullYear();
}
case 'ago':
var date = new Date(this.props.data)
@ -103,11 +108,10 @@ export default class Dater extends React.Component{
return hours + " hours";
} else {
return days + " days"
}
break
};
default:
return null
return null;
}
}
@ -115,7 +119,7 @@ export default class Dater extends React.Component{
if (!this.props.data){
return null;
} else {
return <span className="dater">{ this.calculate() }</span>
return <span className="dater">{ this.calculate() }</span>;
}
}
}

View File

@ -502,6 +502,8 @@ export let formatPlaylist = function(data){
'snapshot_id',
'provider',
'type',
'collaborative',
'public',
'name',
'description',
'images',

View File

@ -22,7 +22,7 @@ class InitialSetup extends React.Component{
super(props);
this.state = {
username: this.props.username,
username: (this.props.username ? this.props.username : 'Anonymous'),
allow_reporting: this.props.allow_reporting,
host: this.props.host,
port: this.props.port
@ -141,7 +141,7 @@ class InitialSetup extends React.Component{
const mapStateToProps = (state, ownProps) => {
return {
allow_reporting: state.ui.allow_reporting,
username: (state.pusher && state.pusher.username ? state.pusher.username : 'Anonymous'),
username: (state.pusher && state.pusher.username ? state.pusher.username : null),
host: state.mopidy.host,
port: state.mopidy.port
}