use moment plugin to calculate duration
This commit is contained in:
parent
9665f1cf4e
commit
d94532b1d9
3 changed files with 6 additions and 4 deletions
|
@ -5,6 +5,8 @@ import RouteMapper from './navigation/RouteMapper';
|
||||||
import GlobalStyles from '../settings/styles';
|
import GlobalStyles from '../settings/styles';
|
||||||
import BusyIndicator from 'react-native-busy-indicator';
|
import BusyIndicator from 'react-native-busy-indicator';
|
||||||
|
|
||||||
|
require('moment-duration-format');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
Navigator,
|
Navigator,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React from 'react-native';
|
import React from 'react-native';
|
||||||
import GlobalStyles from '../../settings/styles';
|
import GlobalStyles from '../../settings/styles';
|
||||||
import { getProjectRecentBuilds } from '../../api/CircleCI';
|
import { getProjectRecentBuilds } from '../../api/CircleCI';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
View,
|
View,
|
||||||
|
@ -68,10 +69,8 @@ export default class ProjectItem extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
_displayMoreInfo(mostRecentBuild) {
|
_displayMoreInfo(mostRecentBuild) {
|
||||||
let seconds = Math.floor(mostRecentBuild.build_time_millis / 1000);
|
const mask = mostRecentBuild.build_time_millis <= 60000 ? 'ss[s]' : 'm:ss';
|
||||||
const minutes = Math.floor(seconds / 60);
|
const buildTime = moment.duration(mostRecentBuild.build_time_millis, 'ms').format(mask);
|
||||||
seconds = seconds - (minutes * 60);
|
|
||||||
const buildTime = minutes + ':' + seconds;
|
|
||||||
const commit = mostRecentBuild.all_commit_details[0];
|
const commit = mostRecentBuild.all_commit_details[0];
|
||||||
return (
|
return (
|
||||||
<View style={styles.buildCell}>
|
<View style={styles.buildCell}>
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"immutable": "=3.7.6",
|
"immutable": "=3.7.6",
|
||||||
"moment": "=2.11.2",
|
"moment": "=2.11.2",
|
||||||
|
"moment-duration-format": "=1.3.0",
|
||||||
"react-native": "=0.20.0",
|
"react-native": "=0.20.0",
|
||||||
"react-native-busy-indicator": "=1.0.6",
|
"react-native-busy-indicator": "=1.0.6",
|
||||||
"react-native-modalbox": "=1.3.1",
|
"react-native-modalbox": "=1.3.1",
|
||||||
|
|
Reference in a new issue