diff options
author | Dessalines <tyhou13@gmx.com> | 2019-03-27 12:54:55 -0700 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2019-03-27 12:54:55 -0700 |
commit | 05f0aee3ea88d3982e2efe6230f8c591540e4c92 (patch) | |
tree | 8b7c39e4928ffd1d6604ef3c5aad604357a031d9 /ui/src/components/moment-time.tsx | |
parent | 2b08fe5be98ba1de0dc3c16f2f3f25ce3c2b262c (diff) |
Adding moment time parsing
Diffstat (limited to 'ui/src/components/moment-time.tsx')
-rw-r--r-- | ui/src/components/moment-time.tsx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ui/src/components/moment-time.tsx b/ui/src/components/moment-time.tsx new file mode 100644 index 00000000..e0886cbc --- /dev/null +++ b/ui/src/components/moment-time.tsx @@ -0,0 +1,28 @@ +import { Component, linkEvent } from 'inferno'; +import * as moment from 'moment'; + +interface MomentTimeProps { + data: { + published: string; + updated?: string; + } +} + +export class MomentTime extends Component<MomentTimeProps, any> { + + constructor(props, context) { + super(props, context); + } + + render() { + if (this.props.data.updated) { + return ( + <span className="font-italics">modified {moment.utc(this.props.data.updated).fromNow()}</span> + ) + } else { + return ( + <span>{moment.utc(this.props.data.published).fromNow()}</span> + ) + } + } +} |