use moment plugin to calculate duration

This commit is contained in:
Jake Howard 2016-03-11 10:32:32 +00:00
parent 9665f1cf4e
commit d94532b1d9
3 changed files with 6 additions and 4 deletions

View file

@ -5,6 +5,8 @@ import RouteMapper from './navigation/RouteMapper';
import GlobalStyles from '../settings/styles';
import BusyIndicator from 'react-native-busy-indicator';
require('moment-duration-format');
const {
Navigator,
StyleSheet,

View file

@ -1,6 +1,7 @@
import React from 'react-native';
import GlobalStyles from '../../settings/styles';
import { getProjectRecentBuilds } from '../../api/CircleCI';
import moment from 'moment';
const {
View,
@ -68,10 +69,8 @@ export default class ProjectItem extends React.Component {
}
_displayMoreInfo(mostRecentBuild) {
let seconds = Math.floor(mostRecentBuild.build_time_millis / 1000);
const minutes = Math.floor(seconds / 60);
seconds = seconds - (minutes * 60);
const buildTime = minutes + ':' + seconds;
const mask = mostRecentBuild.build_time_millis <= 60000 ? 'ss[s]' : 'm:ss';
const buildTime = moment.duration(mostRecentBuild.build_time_millis, 'ms').format(mask);
const commit = mostRecentBuild.all_commit_details[0];
return (
<View style={styles.buildCell}>

View file

@ -10,6 +10,7 @@
"dependencies": {
"immutable": "=3.7.6",
"moment": "=2.11.2",
"moment-duration-format": "=1.3.0",
"react-native": "=0.20.0",
"react-native-busy-indicator": "=1.0.6",
"react-native-modalbox": "=1.3.1",