How to use the date-fns/distance_in_words_to_now function in date-fns

To help you get started, we’ve selected a few date-fns examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coderplex / linklet-app / components / LinkCard.js View on Github external
{link.description ? (
              
            ) : (
              'No Description'
            )}
          <p></p>
        
        <div>
          <div>
            <span>
              {isThisMonth(link.timestamp)
                ? 'Added ' + distanceInWordsToNow(link.timestamp) + ' ' + 'ago'
                : 'Added On ' + format(link.timestamp, 'MMM, Do YYYY')}
            </span>
            <span>
              <a title="bookmark"> {
                  e.preventDefault()
                  this.props.handelLike(link._id)
                }}
                href='#'
              &gt;
                
                <span>{link.bookmarkedBy ? link.bookmarkedBy.length : 0}</span>
              </a>
              <span title="Views"></span></span></div></div>
github wasd171 / chatinder / app / scenes / App / scenes / Main / components / ChatSection / components / ChatHeader / index.jsx View on Github external
@computed get formattedLastSeen() {
		return this.timeFromNow &lt;= 30 ? 'online' : `last seen ${distanceInWordsToNow(this.pingTime, {addSuffix: true})}`
	}
github outline / outline / app / components / Collaborators.js View on Github external
{mostRecentViewers.map(({ lastViewedAt, user }) =&gt; (
          
            
                  <strong>{user.name}</strong>
                  <br>
                  viewed {distanceInWordsToNow(new Date(lastViewedAt))} ago
                
              }
              placement="bottom"
            &gt;
              
                 this.handleOpenProfile(user.id)}
                  size={32}
                /&gt;
github LibreTubeApp / LibreTube / components / SubscriptionList / index.js View on Github external
<div>
          
            <a>
              <img alt="" sizes="(min-width: 600px) 480px, 50vw" srcset="{buildSrcset(video.thumbnails)}">
              <p>{video.title}</p>
              <p>{distanceInWordsToNow(new Date(video.publishedAt))} ago</p>
            </a>
          
          <a rel="noopener noreferrer" href="{`https://youtube.com/channel/${video.channel.id}`}">
            <p>{video.channel.title}</p>
          </a>
        </div>
      ))}
    ,
github clay / clay-kiln / lib / drawers / page-history.vue View on Github external
function formatStatusTime(date) {
    date = date ? new Date(date) : null;

    if (!date || !isValidDate(date)) {
      return null;
    }

    if (isToday(date)) {
      return distanceInWordsToNow(date, { includeSeconds: false, addSuffix: true });
    } else if (isTomorrow(date)) {
      return 'Tomorrow';
    } else if (isYesterday(date)) {
      return 'Yesterday';
    } else if (isThisYear(date)) {
      return dateFormat(date, 'M/D');
    } else {
      return dateFormat(date, 'M/D/YY');
    }
  }
github sanity-io / sanity / packages / @sanity / desk-tool / src / components / ConfirmPublish.js View on Github external
title="Confirm publish"
        centered
        onClose={onCancel}
        onAction={this.handleAction}
        actions={ACTIONS}
      &gt;
        <div style="{{padding:">
          <p>
            Are you sure you would like to publish the document{' '}
            <strong>
              
            </strong>?
          </p>
          <p>
            {published &amp;&amp;
              `It was last published ${distanceInWordsToNow(published._updatedAt, {
                addSuffix: true
              })}.`}
          </p>
        </div>
      
    )
  }
}
github loomnetwork / vue-block-explorer / src / components / block-list.ts View on Github external
async showBlock(blockHeight: number) {
    const block = await this.blockchain.fetchBlock(blockHeight)
    const item = {
      blockHeight: block.height,
      numTransactions: block.numTxs,
      hash: block.hash,
      age: distanceInWordsToNow(new Date(block.time)),
      time: formatDate(new Date(block.time), 'YYYY-MM-DD HH:mm:ss.SSS (Z)'),
      block
    }
    this.selectItem(item)
  }
github zulip / zulip-mobile / src / webview / html / messageTagsAsHtml.js View on Github external
export default (isStarred: boolean, timeEdited: ?number): string =&gt; {
  if (timeEdited === undefined &amp;&amp; !isStarred) {
    return '';
  }

  const editedTime = timeEdited ? distanceInWordsToNow(timeEdited * 1000) : '';

  return template`<div class="message-tags">
  $!${timeEdited ? template`<span class="message-tag">edited ${editedTime} ago</span>` : ''}
  $!${isStarred ? '<span class="message-tag">starred</span>' : ''}
</div>
`;
};
github clay / clay-kiln / lib / drawers / publish-page.vue View on Github external
statusMessage() {
        if (this.isScheduled) {
          return `Scheduled ${distanceInWordsToNow(this.scheduledDate, { addSuffix: true })}`;
        } if (this.isPublished) {
          return `Published ${distanceInWordsToNow(this.publishedDate, { addSuffix: true })}`;
        } else if (this.isArchived) {
          return 'Archived';
        } else if (this.createdDate) {
          return `Draft Created ${distanceInWordsToNow(this.createdDate, { addSuffix: true })}`;
        } else {
          return 'Draft Created some time ago';
        }
      },
      time() {
github clay / clay-kiln / panes / people.vue View on Github external
function formatStatusTime(date) {
    date = date ? new Date(date) : null;

    if (!date || !isValidDate(date)) {
      return null;
    }

    if (isToday(date)) {
      return distanceInWordsToNow(date, { includeSeconds: false, addSuffix: true });
    } else if (isTomorrow(date)) {
      return 'Tomorrow';
    } else if (isYesterday(date)) {
      return 'Yesterday';
    } else if (isThisYear(date)) {
      return dateFormat(date, 'M/D');
    } else {
      return dateFormat(date, 'M/D/YY');
    }
  }