deku-time v0.1.1
deku-time
A component for rendering a datetime using an HTML5
<time>
element. It supports just about any display format supported by moment as well as auto-updating on a set interval.
Example
<Time datetime="now" format="LLLL" />
<Time datetime={createdAt} from="now" refresh="1s" />
<Time datetime={createdAt} calendar="now" />
Attributes
datetime
This determines the date/time to display. Anything accepted by moment is supported, and the value "now" is treated as a special case. (by excluding the attribute altogether, "now" is assumed)
format
If passed, this will render the datetime
using format()
.
from
If passed, this will render the datetime
using from(date)
. (anything accepted by moment is supported)
The value "now" is treated as a special case. (and will use fromNow()
instead)
to
If passed, this will render the datetime
using to(date)
. (anything accepted by moment is supported)
The value "now" is treated as a special case. (and will use toNow()
instead)
calendar
If passed, this will render the datetime
using calendar(date)
. (anything accepted by moment is supported)
The value "now" is treated as a special case.
refresh
If passed, the component will auto-update on the given interval. Generally, this is useful when displaying relative times so that the displayed value doesn't become stale.
class
Used to extend the <time>
element with your own CSS hooks. (passed to magic-virtual-element)