How to use the @formatjs/intl-utils.selectUnit function in @formatjs/intl-utils

To help you get started, we’ve selected a few @formatjs/intl-utils 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 alephdata / aleph / ui / src / components / Notification / Notification.jsx View on Github external
// TODO: Could be done with Array.prototype.reducer very nicely
    parts.forEach((token) => {
      if (token === '{{') {
        paramActive = true;
      } else if (token === '}}') {
        paramActive = false;
      } else if (paramActive) {
        const param = this.getParam(token);
        message.push((<span>{param}</span>));
      } else {
        message.push(token);
      }
    });

    const createdDate = this.convertUTCDateToLocalDate(new Date(createdAt));
    const { value, unit } = selectUnit(createdDate, Date.now());
    return (
      <li>
        <div>
          
        </div>
        {message}
      </li>
    );
  }
}
github itchio / itch / src / renderer / basics / TimeAgo.tsx View on Github external
export const TimeAgo = (props: Props) =&gt; {
  const { className, before, date } = props;

  let dateNumber: number = typeof date === "number" ? date : +new Date(date);
  let dateString: string =
    typeof date === "number" ? new Date(date).toISOString() : date;
  const { value, unit } = selectUnit(dateNumber);

  // TODO: since we're passing a relative value, do we need to update it
  // ourselves now? If so, do we want to? Using hooks maybe?
  // TODO: review react-hint usage
  return (
    <span title="{dateString}">
      {before ? &lt;&gt;{before}  : null}
      
    </span>
  );
};
github zeit / next.js / examples / with-react-intl / pages / about.js View on Github external
export default () =&gt; {
  const { value, unit } = selectUnit(Date.now())
  return (
    
      <p>
        
      </p>
    
  )
}
github ia-toki / judgels / judgels-frontends / raphael / src / components / FormattedRelative / FormattedRelative.tsx View on Github external
export const FormattedRelative = (props: FormattedRelativeProps) =&gt; {
  const { value, unit } = selectUnit(props.value);
  return ;
};