beaulebens / keyring-social-importers

A collection of importers which pull your content back from social networks, and into your own WordPress install.
32 stars 17 forks source link

Duration in Fitbit is formatted incorrectly #6

Closed davidwolfpaw closed 7 years ago

davidwolfpaw commented 7 years ago

My Fitbit data is pulled in minutes, not seconds. I had to rewrite the following function in my replacement importer from

function format_duration( $num ) {
    if ( $num < 3600 ) {
        return sprintf( __( '%s minutes', 'keyring' ), round( $num / 60 ) );
    } else {
        $hours = floor( $num / 60 / 60 );
        $num = $num - ( $hours * 60 * 60 );
        return sprintf( __( '%1$s hours, %2$s minutes', 'keyring' ), $hours, round( $num / 60 ) );
    }
}   

to

function format_duration( $num ) {
    if ( $num < 60 ) {
        return sprintf( __( '%s minutes', 'keyring' ), $num );
    } else {
        $hours = floor( $num / 60 );
        $min = $num - ( $hours * 60 );
        return sprintf( __( '%1$s hours, %2$s minutes', 'keyring' ), $hours, $min );
    }
}