Download spectrum/src/components/inboxThread/header/timestamp.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 765 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/src/components/inboxThread/header/timestamp.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/src/components/inboxThread/header/timestamp.js
-
curl -L -o timestamp.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/src/components/inboxThread/header/timestamp.js
765 Bytes
| // @flow | |
| import * as React from 'react'; | |
| import { timeDifferenceShort } from 'shared/time-difference'; | |
| import { Timestamp } from './style'; | |
| import type { HeaderProps } from './index'; | |
| class ThreadTimestamp extends React.Component<HeaderProps> { | |
| render() { | |
| const { thread, active } = this.props; | |
| const now = new Date().getTime(); | |
| const then = thread.lastActive || thread.createdAt; | |
| let timestamp = timeDifferenceShort(now, new Date(then).getTime()); | |
| // show 'just now' instead of '0s' for new threads | |
| if (timestamp.slice(-1) === 's') { | |
| timestamp = 'Just now'; | |
| } | |
| return ( | |
| <React.Fragment> | |
| <Timestamp active={active}>{timestamp}</Timestamp> | |
| </React.Fragment> | |
| ); | |
| } | |
| } | |
| export default ThreadTimestamp; | |