forked from vergnet/application-amicale
Use pretty date formatting
This commit is contained in:
parent
07d8fb8d15
commit
b29973189f
1 changed files with 18 additions and 2 deletions
|
@ -85,6 +85,22 @@ class TetrisScreen extends React.Component<Props, State> {
|
||||||
this.showPausePopup();
|
this.showPausePopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFormattedTime(seconds: number) {
|
||||||
|
let date = new Date();
|
||||||
|
date.setHours(0);
|
||||||
|
date.setMinutes(0);
|
||||||
|
date.setSeconds(seconds);
|
||||||
|
let format;
|
||||||
|
console.log(date);
|
||||||
|
if (date.getHours())
|
||||||
|
format = date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
|
||||||
|
else if (date.getMinutes())
|
||||||
|
format = date.getMinutes() + ':' + date.getSeconds();
|
||||||
|
else
|
||||||
|
format = date.getSeconds();
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
onTick(score: number, level: number, newGrid: Array<Array<Object>>) {
|
onTick(score: number, level: number, newGrid: Array<Array<Object>>) {
|
||||||
this.setState({
|
this.setState({
|
||||||
gameScore: score,
|
gameScore: score,
|
||||||
|
@ -145,7 +161,7 @@ class TetrisScreen extends React.Component<Props, State> {
|
||||||
showGameOverConfirm() {
|
showGameOverConfirm() {
|
||||||
let message = 'SCORE: ' + this.state.gameScore + '\n';
|
let message = 'SCORE: ' + this.state.gameScore + '\n';
|
||||||
message += 'LEVEL: ' + this.state.gameLevel + '\n';
|
message += 'LEVEL: ' + this.state.gameLevel + '\n';
|
||||||
message += 'TIME: ' + this.state.gameTime + '\n';
|
message += 'TIME: ' + this.getFormattedTime(this.state.gameTime) + '\n';
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
'GAME OVER',
|
'GAME OVER',
|
||||||
message,
|
message,
|
||||||
|
@ -193,7 +209,7 @@ class TetrisScreen extends React.Component<Props, State> {
|
||||||
<Text style={{
|
<Text style={{
|
||||||
marginLeft: 5,
|
marginLeft: 5,
|
||||||
color: this.colors.subtitle
|
color: this.colors.subtitle
|
||||||
}}>{this.state.gameTime}</Text>
|
}}>{this.getFormattedTime(this.state.gameTime)}</Text>
|
||||||
</View>
|
</View>
|
||||||
<View style={{
|
<View style={{
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
|
|
Loading…
Reference in a new issue