Files
fuzzy-date/fuzzy-date.html
2018-03-16 09:19:27 +01:00

42 lines
897 B
HTML

<link rel="import" href="../polymer/polymer-element.html">
<script src="../moment/moment.js"></script>
<dom-module id="fuzzy-date">
<template>
<style>
:host {
display: block;
}
</style>
<span>[[_formatDate(date)]]</span>
</template>
<script>
/**
* `fuzzy-date`
* A simple element that shows dates in a format understood by humans
*
* @customElement
* @polymer
* @demo demo/index.html
*/
class FuzzyDate extends Polymer.Element {
static get is() { return 'fuzzy-date'; }
static get properties() {
return {
date: {
type: String,
reflectToAttribute: true
}
};
}
_formatDate(dateString){
return moment(dateString).fromNow();
}
}
window.customElements.define(FuzzyDate.is, FuzzyDate);
</script>
</dom-module>