universoimpulso/atena

View on GitHub
src/controllers/RankingController/utils.js

Summary

Maintainability
A
0 mins
Test Coverage
import moment from 'moment'

export default class RankingUtils {
  getDate({ year, month }) {
    if (!year || !month)
      return {
        date: moment().toDate(),
        monthName: moment().locale('pt').format('MMMM')
      }

    const fullDate = moment(`${year}/${month}`, 'YYYY/MM').toDate()

    return {
      date: fullDate,
      monthName: moment(fullDate).locale('pt').format('MMMM')
    }
  }
}