I made a package
@tozd/vue-format-time which provides efficient reactive time formatting helpers for Vue. For example, a timestamp can be formatted into a relative description based on current time. As time progresses, relative description is automatically updated (
1 minute ago ,
2 minutes ago , etc.).
- Efficient. If next change to the formatted timestamp is in one hour (i.e., currently description says
1 hour agoand only one hour later it should change to
2 hours ago), timestamp will be reformatted only once, in an hour. Not at regular intervals just to discover the description has not changed.
- Uses Moment.js to parse timestamps and format them.
- Localization. Most strings can be localized through Moment.js, the rest using
vue-gettextor a compatible API.
Any feedback welcome.