export default {
    formatTime(time) {
        var minutes = Math.floor(time / 60) || 0
        var seconds = Math.round((time - minutes * 60) || 0)

        return `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`
    },
    declOfNum (n, titles) {
        return titles[n % 10 === 1 && n % 100 !== 11 ?
            0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2]
    },
    declNumPosts(number){
        const array_word = ['публикация', 'публикации', 'публикаций']
        return this.declOfNum(number, array_word)
    },
    declNumReaders(number){
        const array_word = ['подписка', 'подписок', 'подписок']
        return this.declOfNum(number, array_word)
    },
    declNumSubs(number){
        const array_word = ['подписчик', 'подписчика', 'подписчиков']
        return this.declOfNum(number, array_word)
    }
}
