summaryrefslogtreecommitdiff
path: root/date-fns/src/locale/pt-BR/_lib/formatRelative/index.js
blob: 4ce6c4d7feeab3623678462d2a42dcfedb631565 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var formatRelativeLocale = {
  lastWeek: function(date, _baseDate, _options) {
    var weekday = date.getUTCDay()
    var last = weekday === 0 || weekday === 6 ? 'último' : 'última'
    return "'" + last + "' eeee 'às' p"
  },
  yesterday: "'ontem às' p",
  today: "'hoje às' p",
  tomorrow: "'amanhã às' p",
  nextWeek: "eeee 'às' p",
  other: 'P'
}

export default function formatRelative(token, date, baseDate, options) {
  var format = formatRelativeLocale[token]

  if (typeof format === 'function') {
    return format(date, baseDate, options)
  }

  return format
}