import differenceInDays from "date-fns/differenceInCalendarDays"
import formatDistance from "date-fns/formatDistance"
import parseISO from "date-fns/parseISO"
import toDate from "date-fns/toDate"

import isString from "lodash/isString"

/**
 * Returns human-readable distance between the Date.now() and given date
 *
 * @param {string | number | Date} date
 *
 * @return {string}
 */
function formatDateProximity(date) {
  const now = Date.now()

  if (isString(date)) {
    date = parseISO(date)
  }

  date = toDate(date)

  switch (Math.abs(differenceInDays(date, now))) {
    case 0:
      return "Today"
    case 1:
      return "Yesterday"
    default:
      return formatDistance(date, now, {addSuffix: true})
  }
}

export default formatDateProximity

@@ -188,16 +188,53 @@
 /toDate%22
+%0Aimport format from %22date-fns/format%22
 %0A%0Aimport
@@ -267,16 +267,41 @@
 tring%22%0A%0A
+const pattern = %22HH:mm%22%0A%0A
 /**%0A * R
@@ -660,15 +660,43 @@
 urn 
-%22
+%60
 Today
-%22
+ at $%7Bformat(date, pattern)%7D%60
 %0A   
@@ -717,17 +717,17 @@
  return 
-%22
+%60
 Yesterda
@@ -727,17 +727,45 @@
 esterday
-%22
+ at $%7Bformat(date, pattern)%7D%60
 %0A    def

Improve formatDateProximity helper