您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

TimeElapsed.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* @flow */
  2. import React, { Component } from 'react';
  3. import { translate } from '../../../base/i18n';
  4. import { createLocalizedTime } from '../timeFunctions';
  5. /**
  6. * The type of the React {@code Component} props of {@link TimeElapsed}.
  7. */
  8. type Props = {
  9. /**
  10. * The function to translate human-readable text.
  11. */
  12. t: Function,
  13. /**
  14. * The milliseconds to be converted into a human-readable format.
  15. */
  16. time: number
  17. };
  18. /**
  19. * React component for displaying total time elapsed. Converts a total count of
  20. * milliseconds into a more humanized form: "# hours, # minutes, # seconds".
  21. * With a time of 0, "0s" will be displayed.
  22. *
  23. * @augments Component
  24. */
  25. class TimeElapsed extends Component<Props> {
  26. /**
  27. * Implements React's {@link Component#render()}.
  28. *
  29. * @inheritdoc
  30. * @returns {ReactElement}
  31. */
  32. render() {
  33. const { time, t } = this.props;
  34. const timeElapsed = createLocalizedTime(time, t);
  35. return (
  36. <div>
  37. { timeElapsed }
  38. </div>
  39. );
  40. }
  41. }
  42. export default translate(TimeElapsed);