This step provides a sample element with a template. Go ahead and try importing your directive, and then use it in a template.
import {timeAgo} from'./time-ago.js';
Next, create a Date object at the module-level, above the TimeAgoExample class definition that we'll use to pass to the directive, just to see it working:
consttimeCreated=newDate();
@customElement('time-ago-example')
exportclassTimeAgoExampleextendsLitElement {
...
consttimeCreated=newDate();
exportclassTimeAgoExampleextendsLitElement {
...
And then call the directive from the template:
returnhtml`
<p>This page was rendered ${timeAgo(timeCreated)}.</p>
`;
You should see the directive output the Date as a string. The next step will format it as elapsed time instead.