Socket
Socket
Sign inDemoInstall

vue-timeago3

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-timeago3 - npm Package Compare versions

Comparing version 2.1.0 to 2.1.2

2

dist/vue-timeago.es.js

@@ -951,3 +951,3 @@ import { defineComponent, ref, onBeforeMount, onBeforeUnmount, watch, h } from "vue";

});
return { timeago };
return { timeago, updateTimer };
},

@@ -954,0 +954,0 @@ render() {

@@ -1,1 +0,1 @@

(function(v,c){typeof exports=="object"&&typeof module!="undefined"?c(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],c):(v=typeof globalThis!="undefined"?globalThis:v||self,c(v.VueTimeago3={},v.Vue))})(this,function(v,c){"use strict";function x(e){if(e===null||e===!0||e===!1)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function h(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function d(e){h(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"),console.warn(new Error().stack)),new Date(NaN))}function N(e){var t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}function b(e,t){h(2,arguments);var n=d(e),a=d(t),i=n.getTime()-a.getTime();return i<0?-1:i>0?1:i}function F(e,t){h(2,arguments);var n=d(e),a=d(t),i=n.getFullYear()-a.getFullYear(),r=n.getMonth()-a.getMonth();return i*12+r}function _(e,t){return h(2,arguments),d(e).getTime()-d(t).getTime()}var P={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(e){return e<0?Math.ceil(e):Math.floor(e)}},A="trunc";function k(e){return e?P[e]:P[A]}function Y(e){h(1,arguments);var t=d(e);return t.setHours(23,59,59,999),t}function j(e){h(1,arguments);var t=d(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function E(e){h(1,arguments);var t=d(e);return Y(t).getTime()===j(t).getTime()}function R(e,t){h(2,arguments);var n=d(e),a=d(t),i=b(n,a),r=Math.abs(F(n,a)),o;if(r<1)o=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-i*r);var s=b(n,a)===-i;E(d(e))&&r===1&&b(e,a)===1&&(s=!1),o=i*(r-Number(s))}return o===0?0:o}function X(e,t,n){h(2,arguments);var a=_(e,t)/1e3;return k(n==null?void 0:n.roundingMethod)(a)}var q={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},z=function(e,t,n){var a,i=q[e];return typeof i=="string"?a=i:t===1?a=i.one:a=i.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+a:a+" ago":a},L=z;function D(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.width?String(t.width):e.defaultWidth,a=e.formats[n]||e.formats[e.defaultWidth];return a}}var V={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},H={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},$={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},J={date:D({formats:V,defaultWidth:"full"}),time:D({formats:H,defaultWidth:"full"}),dateTime:D({formats:$,defaultWidth:"full"})},B=J,Q={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Z=function(e,t,n,a){return Q[e]},G=Z;function g(e){return function(t,n){var a=n||{},i=a.context?String(a.context):"standalone",r;if(i==="formatting"&&e.formattingValues){var o=e.defaultFormattingWidth||e.defaultWidth,s=a.width?String(a.width):o;r=e.formattingValues[s]||e.formattingValues[o]}else{var f=e.defaultWidth,l=a.width?String(a.width):e.defaultWidth;r=e.values[l]||e.values[f]}var u=e.argumentCallback?e.argumentCallback(t):t;return r[u]}}var K={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ee={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},te={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},ne={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},ae={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},re={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},ie=function(e,t){var n=Number(e),a=n%100;if(a>20||a<10)switch(a%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},oe={ordinalNumber:ie,era:g({values:K,defaultWidth:"wide"}),quarter:g({values:ee,defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:g({values:te,defaultWidth:"wide"}),day:g({values:ne,defaultWidth:"wide"}),dayPeriod:g({values:ae,defaultWidth:"wide",formattingValues:re,defaultFormattingWidth:"wide"})},ue=oe;function p(e){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.width,i=a&&e.matchPatterns[a]||e.matchPatterns[e.defaultMatchWidth],r=t.match(i);if(!r)return null;var o=r[0],s=a&&e.parsePatterns[a]||e.parsePatterns[e.defaultParseWidth],f=Array.isArray(s)?le(s,function(m){return m.test(o)}):se(s,function(m){return m.test(o)}),l;l=e.valueCallback?e.valueCallback(f):f,l=n.valueCallback?n.valueCallback(l):l;var u=t.slice(o.length);return{value:l,rest:u}}}function se(e,t){for(var n in e)if(e.hasOwnProperty(n)&&t(e[n]))return n}function le(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return n}function fe(e){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=t.match(e.matchPattern);if(!a)return null;var i=a[0],r=t.match(e.parsePattern);if(!r)return null;var o=e.valueCallback?e.valueCallback(r[0]):r[0];o=n.valueCallback?n.valueCallback(o):o;var s=t.slice(i.length);return{value:o,rest:s}}}var de=/^(\d+)(th|st|nd|rd)?/i,me=/\d+/i,ce={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},he={any:[/^b/i,/^(a|c)/i]},ve={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ge={any:[/1/i,/2/i,/3/i,/4/i]},pe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Me={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},be={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},we={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},De={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},ye={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Te={ordinalNumber:fe({matchPattern:de,parsePattern:me,valueCallback:function(e){return parseInt(e,10)}}),era:p({matchPatterns:ce,defaultMatchWidth:"wide",parsePatterns:he,defaultParseWidth:"any"}),quarter:p({matchPatterns:ve,defaultMatchWidth:"wide",parsePatterns:ge,defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:p({matchPatterns:pe,defaultMatchWidth:"wide",parsePatterns:Me,defaultParseWidth:"any"}),day:p({matchPatterns:be,defaultMatchWidth:"wide",parsePatterns:we,defaultParseWidth:"any"}),dayPeriod:p({matchPatterns:De,defaultMatchWidth:"any",parsePatterns:ye,defaultParseWidth:"any"})},Se=Te,Ne={code:"en-US",formatDistance:L,formatLong:B,formatRelative:G,localize:ue,match:Se,options:{weekStartsOn:0,firstWeekContainsDate:1}},Pe=Ne;function We(e,t){if(e==null)throw new TypeError("assign requires that input parameter not be null or undefined");t=t||{};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function Ie(e){return We({},e)}var W=1440,Ce=2520,y=43200,Oe=86400;function Ue(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};h(2,arguments);var a=n.locale||Pe;if(!a.formatDistance)throw new RangeError("locale must contain formatDistance property");var i=b(e,t);if(isNaN(i))throw new RangeError("Invalid time value");var r=Ie(n);r.addSuffix=Boolean(n.addSuffix),r.comparison=i;var o,s;i>0?(o=d(t),s=d(e)):(o=d(e),s=d(t));var f=X(s,o),l=(N(s)-N(o))/1e3,u=Math.round((f-l)/60),m;if(u<2)return n.includeSeconds?f<5?a.formatDistance("lessThanXSeconds",5,r):f<10?a.formatDistance("lessThanXSeconds",10,r):f<20?a.formatDistance("lessThanXSeconds",20,r):f<40?a.formatDistance("halfAMinute",null,r):f<60?a.formatDistance("lessThanXMinutes",1,r):a.formatDistance("xMinutes",1,r):u===0?a.formatDistance("lessThanXMinutes",1,r):a.formatDistance("xMinutes",u,r);if(u<45)return a.formatDistance("xMinutes",u,r);if(u<90)return a.formatDistance("aboutXHours",1,r);if(u<W){var Ke=Math.round(u/60);return a.formatDistance("aboutXHours",Ke,r)}else{if(u<Ce)return a.formatDistance("xDays",1,r);if(u<y){var et=Math.round(u/W);return a.formatDistance("xDays",et,r)}else if(u<Oe)return m=Math.round(u/y),a.formatDistance("aboutXMonths",m,r)}if(m=R(s,o),m<12){var tt=Math.round(u/y);return a.formatDistance("xMonths",tt,r)}else{var U=m%12,S=Math.floor(m/12);return U<3?a.formatDistance("aboutXYears",S,r):U<9?a.formatDistance("overXYears",S,r):a.formatDistance("almostXYears",S+1,r)}}function xe(e,t){return h(1,arguments),Ue(e,Date.now(),t)}var I=36e5,C=6e4,Fe=2,w={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},_e=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Ae=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,ke=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Ye(e,t){h(1,arguments);var n=t||{},a=n.additionalDigits==null?Fe:x(n.additionalDigits);if(a!==2&&a!==1&&a!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(!(typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"))return new Date(NaN);var i=je(e),r;if(i.date){var o=Ee(i.date,a);r=Re(o.restDateString,o.year)}if(isNaN(r)||!r)return new Date(NaN);var s=r.getTime(),f=0,l;if(i.time&&(f=Xe(i.time),isNaN(f)||f===null))return new Date(NaN);if(i.timezone){if(l=qe(i.timezone),isNaN(l))return new Date(NaN)}else{var u=new Date(s+f),m=new Date(0);return m.setFullYear(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate()),m.setHours(u.getUTCHours(),u.getUTCMinutes(),u.getUTCSeconds(),u.getUTCMilliseconds()),m}return new Date(s+f+l)}function je(e){var t={},n=e.split(w.dateTimeDelimiter),a;if(n.length>2)return t;if(/:/.test(n[0])?(t.date=null,a=n[0]):(t.date=n[0],a=n[1],w.timeZoneDelimiter.test(t.date)&&(t.date=e.split(w.timeZoneDelimiter)[0],a=e.substr(t.date.length,e.length))),a){var i=w.timezone.exec(a);i?(t.time=a.replace(i[1],""),t.timezone=i[1]):t.time=a}return t}function Ee(e,t){var n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),a=e.match(n);if(!a)return{year:null};var i=a[1]&&parseInt(a[1]),r=a[2]&&parseInt(a[2]);return{year:r==null?i:r*100,restDateString:e.slice((a[1]||a[2]).length)}}function Re(e,t){if(t===null)return null;var n=e.match(_e);if(!n)return null;var a=!!n[4],i=M(n[1]),r=M(n[2])-1,o=M(n[3]),s=M(n[4]),f=M(n[5])-1;if(a)return $e(t,s,f)?ze(t,s,f):new Date(NaN);var l=new Date(0);return!Ve(t,r,o)||!He(t,i)?new Date(NaN):(l.setUTCFullYear(t,r,Math.max(i,o)),l)}function M(e){return e?parseInt(e):1}function Xe(e){var t=e.match(Ae);if(!t)return null;var n=T(t[1]),a=T(t[2]),i=T(t[3]);return Je(n,a,i)?n*I+a*C+i*1e3:NaN}function T(e){return e&&parseFloat(e.replace(",","."))||0}function qe(e){if(e==="Z")return 0;var t=e.match(ke);if(!t)return 0;var n=t[1]==="+"?-1:1,a=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return Be(a,i)?n*(a*I+i*C):NaN}function ze(e,t,n){var a=new Date(0);a.setUTCFullYear(e,0,4);var i=a.getUTCDay()||7,r=(t-1)*7+n+1-i;return a.setUTCDate(a.getUTCDate()+r),a}var Le=[31,null,31,30,31,30,31,31,30,31,30,31];function O(e){return e%400==0||e%4==0&&e%100}function Ve(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(Le[t]||(O(e)?29:28))}function He(e,t){return t>=1&&t<=(O(e)?366:365)}function $e(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function Je(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function Be(e,t){return t>=0&&t<=59}var Qe=(e,t={},n)=>{typeof e=="string"&&(e=Ye(e));const{includeSeconds:a,addSuffix:i=!0}=t;return xe(e,{includeSeconds:a,addSuffix:i,locale:n})};const Ze=(e={})=>{const t=e.name||"Timeago";return c.defineComponent({name:t,props:{datetime:{type:[String,Number,Date],required:!0},title:{type:[String,Boolean],required:!1,default:null},autoUpdate:{type:[Number,Boolean],required:!1,default:null},converter:{type:Function,required:!1,default:null},converterOptions:{type:Object,required:!1,default:null},locale:{type:Object,required:!1,default:null}},setup(n){const a=c.ref();c.onBeforeMount(()=>{s()}),c.onBeforeUnmount(()=>{f()});const i=l=>(n.converter||Qe)(l||n.datetime,n.converterOptions||e.converterOptions,n.locale||e.locale),r=c.ref(i()),o=l=>{r.value=i(l)},s=()=>{if(n.autoUpdate){const l=n.autoUpdate===!0?60:n.autoUpdate;a.value=setInterval(()=>{o(n.datetime)},l*1e3)}},f=()=>{a.value&&(clearInterval(a.value),a.value=void 0)};return c.watch(()=>n.autoUpdate,l=>{f(),l&&s()}),c.watch(()=>[n.datetime,n.converter],()=>{o()}),c.watch(()=>n.converterOptions,()=>{o()},{deep:!0}),{timeago:r}},render(){return c.h("timeago",{attrs:{datetime:new Date(this.datetime).toISOString(),title:typeof this.title=="string"?this.title:this.title===!1?null:this.timeago}},[this.timeago])}})};var Ge=(e,t)=>{if(e.config.globalProperties.$timeago)return;Number(e.version.split(".")[0])<3&&console.warn("[vue-timeago3] This plugin requires at least Vue version 3.0");const a=Ze(t);e.component(a.name,a)};v.default=Ge,Object.defineProperty(v,"__esModule",{value:!0}),v[Symbol.toStringTag]="Module"});
(function(v,c){typeof exports=="object"&&typeof module!="undefined"?c(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],c):(v=typeof globalThis!="undefined"?globalThis:v||self,c(v.VueTimeago3={},v.Vue))})(this,function(v,c){"use strict";function x(e){if(e===null||e===!0||e===!1)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function h(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function d(e){h(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"),console.warn(new Error().stack)),new Date(NaN))}function N(e){var t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}function b(e,t){h(2,arguments);var n=d(e),a=d(t),i=n.getTime()-a.getTime();return i<0?-1:i>0?1:i}function F(e,t){h(2,arguments);var n=d(e),a=d(t),i=n.getFullYear()-a.getFullYear(),r=n.getMonth()-a.getMonth();return i*12+r}function _(e,t){return h(2,arguments),d(e).getTime()-d(t).getTime()}var P={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(e){return e<0?Math.ceil(e):Math.floor(e)}},A="trunc";function k(e){return e?P[e]:P[A]}function Y(e){h(1,arguments);var t=d(e);return t.setHours(23,59,59,999),t}function j(e){h(1,arguments);var t=d(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function E(e){h(1,arguments);var t=d(e);return Y(t).getTime()===j(t).getTime()}function R(e,t){h(2,arguments);var n=d(e),a=d(t),i=b(n,a),r=Math.abs(F(n,a)),o;if(r<1)o=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-i*r);var s=b(n,a)===-i;E(d(e))&&r===1&&b(e,a)===1&&(s=!1),o=i*(r-Number(s))}return o===0?0:o}function X(e,t,n){h(2,arguments);var a=_(e,t)/1e3;return k(n==null?void 0:n.roundingMethod)(a)}var q={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},z=function(e,t,n){var a,i=q[e];return typeof i=="string"?a=i:t===1?a=i.one:a=i.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+a:a+" ago":a},L=z;function D(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.width?String(t.width):e.defaultWidth,a=e.formats[n]||e.formats[e.defaultWidth];return a}}var V={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},H={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},$={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},J={date:D({formats:V,defaultWidth:"full"}),time:D({formats:H,defaultWidth:"full"}),dateTime:D({formats:$,defaultWidth:"full"})},B=J,Q={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Z=function(e,t,n,a){return Q[e]},G=Z;function g(e){return function(t,n){var a=n||{},i=a.context?String(a.context):"standalone",r;if(i==="formatting"&&e.formattingValues){var o=e.defaultFormattingWidth||e.defaultWidth,s=a.width?String(a.width):o;r=e.formattingValues[s]||e.formattingValues[o]}else{var f=e.defaultWidth,l=a.width?String(a.width):e.defaultWidth;r=e.values[l]||e.values[f]}var u=e.argumentCallback?e.argumentCallback(t):t;return r[u]}}var K={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ee={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},te={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},ne={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},ae={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},re={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},ie=function(e,t){var n=Number(e),a=n%100;if(a>20||a<10)switch(a%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},oe={ordinalNumber:ie,era:g({values:K,defaultWidth:"wide"}),quarter:g({values:ee,defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:g({values:te,defaultWidth:"wide"}),day:g({values:ne,defaultWidth:"wide"}),dayPeriod:g({values:ae,defaultWidth:"wide",formattingValues:re,defaultFormattingWidth:"wide"})},ue=oe;function p(e){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.width,i=a&&e.matchPatterns[a]||e.matchPatterns[e.defaultMatchWidth],r=t.match(i);if(!r)return null;var o=r[0],s=a&&e.parsePatterns[a]||e.parsePatterns[e.defaultParseWidth],f=Array.isArray(s)?le(s,function(m){return m.test(o)}):se(s,function(m){return m.test(o)}),l;l=e.valueCallback?e.valueCallback(f):f,l=n.valueCallback?n.valueCallback(l):l;var u=t.slice(o.length);return{value:l,rest:u}}}function se(e,t){for(var n in e)if(e.hasOwnProperty(n)&&t(e[n]))return n}function le(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return n}function fe(e){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=t.match(e.matchPattern);if(!a)return null;var i=a[0],r=t.match(e.parsePattern);if(!r)return null;var o=e.valueCallback?e.valueCallback(r[0]):r[0];o=n.valueCallback?n.valueCallback(o):o;var s=t.slice(i.length);return{value:o,rest:s}}}var de=/^(\d+)(th|st|nd|rd)?/i,me=/\d+/i,ce={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},he={any:[/^b/i,/^(a|c)/i]},ve={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ge={any:[/1/i,/2/i,/3/i,/4/i]},pe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Me={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},be={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},we={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},De={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},ye={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Te={ordinalNumber:fe({matchPattern:de,parsePattern:me,valueCallback:function(e){return parseInt(e,10)}}),era:p({matchPatterns:ce,defaultMatchWidth:"wide",parsePatterns:he,defaultParseWidth:"any"}),quarter:p({matchPatterns:ve,defaultMatchWidth:"wide",parsePatterns:ge,defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:p({matchPatterns:pe,defaultMatchWidth:"wide",parsePatterns:Me,defaultParseWidth:"any"}),day:p({matchPatterns:be,defaultMatchWidth:"wide",parsePatterns:we,defaultParseWidth:"any"}),dayPeriod:p({matchPatterns:De,defaultMatchWidth:"any",parsePatterns:ye,defaultParseWidth:"any"})},Se=Te,Ne={code:"en-US",formatDistance:L,formatLong:B,formatRelative:G,localize:ue,match:Se,options:{weekStartsOn:0,firstWeekContainsDate:1}},Pe=Ne;function We(e,t){if(e==null)throw new TypeError("assign requires that input parameter not be null or undefined");t=t||{};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function Ie(e){return We({},e)}var W=1440,Ce=2520,y=43200,Oe=86400;function Ue(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};h(2,arguments);var a=n.locale||Pe;if(!a.formatDistance)throw new RangeError("locale must contain formatDistance property");var i=b(e,t);if(isNaN(i))throw new RangeError("Invalid time value");var r=Ie(n);r.addSuffix=Boolean(n.addSuffix),r.comparison=i;var o,s;i>0?(o=d(t),s=d(e)):(o=d(e),s=d(t));var f=X(s,o),l=(N(s)-N(o))/1e3,u=Math.round((f-l)/60),m;if(u<2)return n.includeSeconds?f<5?a.formatDistance("lessThanXSeconds",5,r):f<10?a.formatDistance("lessThanXSeconds",10,r):f<20?a.formatDistance("lessThanXSeconds",20,r):f<40?a.formatDistance("halfAMinute",null,r):f<60?a.formatDistance("lessThanXMinutes",1,r):a.formatDistance("xMinutes",1,r):u===0?a.formatDistance("lessThanXMinutes",1,r):a.formatDistance("xMinutes",u,r);if(u<45)return a.formatDistance("xMinutes",u,r);if(u<90)return a.formatDistance("aboutXHours",1,r);if(u<W){var Ke=Math.round(u/60);return a.formatDistance("aboutXHours",Ke,r)}else{if(u<Ce)return a.formatDistance("xDays",1,r);if(u<y){var et=Math.round(u/W);return a.formatDistance("xDays",et,r)}else if(u<Oe)return m=Math.round(u/y),a.formatDistance("aboutXMonths",m,r)}if(m=R(s,o),m<12){var tt=Math.round(u/y);return a.formatDistance("xMonths",tt,r)}else{var U=m%12,S=Math.floor(m/12);return U<3?a.formatDistance("aboutXYears",S,r):U<9?a.formatDistance("overXYears",S,r):a.formatDistance("almostXYears",S+1,r)}}function xe(e,t){return h(1,arguments),Ue(e,Date.now(),t)}var I=36e5,C=6e4,Fe=2,w={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},_e=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Ae=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,ke=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Ye(e,t){h(1,arguments);var n=t||{},a=n.additionalDigits==null?Fe:x(n.additionalDigits);if(a!==2&&a!==1&&a!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(!(typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"))return new Date(NaN);var i=je(e),r;if(i.date){var o=Ee(i.date,a);r=Re(o.restDateString,o.year)}if(isNaN(r)||!r)return new Date(NaN);var s=r.getTime(),f=0,l;if(i.time&&(f=Xe(i.time),isNaN(f)||f===null))return new Date(NaN);if(i.timezone){if(l=qe(i.timezone),isNaN(l))return new Date(NaN)}else{var u=new Date(s+f),m=new Date(0);return m.setFullYear(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate()),m.setHours(u.getUTCHours(),u.getUTCMinutes(),u.getUTCSeconds(),u.getUTCMilliseconds()),m}return new Date(s+f+l)}function je(e){var t={},n=e.split(w.dateTimeDelimiter),a;if(n.length>2)return t;if(/:/.test(n[0])?(t.date=null,a=n[0]):(t.date=n[0],a=n[1],w.timeZoneDelimiter.test(t.date)&&(t.date=e.split(w.timeZoneDelimiter)[0],a=e.substr(t.date.length,e.length))),a){var i=w.timezone.exec(a);i?(t.time=a.replace(i[1],""),t.timezone=i[1]):t.time=a}return t}function Ee(e,t){var n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),a=e.match(n);if(!a)return{year:null};var i=a[1]&&parseInt(a[1]),r=a[2]&&parseInt(a[2]);return{year:r==null?i:r*100,restDateString:e.slice((a[1]||a[2]).length)}}function Re(e,t){if(t===null)return null;var n=e.match(_e);if(!n)return null;var a=!!n[4],i=M(n[1]),r=M(n[2])-1,o=M(n[3]),s=M(n[4]),f=M(n[5])-1;if(a)return $e(t,s,f)?ze(t,s,f):new Date(NaN);var l=new Date(0);return!Ve(t,r,o)||!He(t,i)?new Date(NaN):(l.setUTCFullYear(t,r,Math.max(i,o)),l)}function M(e){return e?parseInt(e):1}function Xe(e){var t=e.match(Ae);if(!t)return null;var n=T(t[1]),a=T(t[2]),i=T(t[3]);return Je(n,a,i)?n*I+a*C+i*1e3:NaN}function T(e){return e&&parseFloat(e.replace(",","."))||0}function qe(e){if(e==="Z")return 0;var t=e.match(ke);if(!t)return 0;var n=t[1]==="+"?-1:1,a=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return Be(a,i)?n*(a*I+i*C):NaN}function ze(e,t,n){var a=new Date(0);a.setUTCFullYear(e,0,4);var i=a.getUTCDay()||7,r=(t-1)*7+n+1-i;return a.setUTCDate(a.getUTCDate()+r),a}var Le=[31,null,31,30,31,30,31,31,30,31,30,31];function O(e){return e%400==0||e%4==0&&e%100}function Ve(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(Le[t]||(O(e)?29:28))}function He(e,t){return t>=1&&t<=(O(e)?366:365)}function $e(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function Je(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function Be(e,t){return t>=0&&t<=59}var Qe=(e,t={},n)=>{typeof e=="string"&&(e=Ye(e));const{includeSeconds:a,addSuffix:i=!0}=t;return xe(e,{includeSeconds:a,addSuffix:i,locale:n})};const Ze=(e={})=>{const t=e.name||"Timeago";return c.defineComponent({name:t,props:{datetime:{type:[String,Number,Date],required:!0},title:{type:[String,Boolean],required:!1,default:null},autoUpdate:{type:[Number,Boolean],required:!1,default:null},converter:{type:Function,required:!1,default:null},converterOptions:{type:Object,required:!1,default:null},locale:{type:Object,required:!1,default:null}},setup(n){const a=c.ref();c.onBeforeMount(()=>{s()}),c.onBeforeUnmount(()=>{f()});const i=l=>(n.converter||Qe)(l||n.datetime,n.converterOptions||e.converterOptions,n.locale||e.locale),r=c.ref(i()),o=l=>{r.value=i(l)},s=()=>{if(n.autoUpdate){const l=n.autoUpdate===!0?60:n.autoUpdate;a.value=setInterval(()=>{o(n.datetime)},l*1e3)}},f=()=>{a.value&&(clearInterval(a.value),a.value=void 0)};return c.watch(()=>n.autoUpdate,l=>{f(),l&&s()}),c.watch(()=>[n.datetime,n.converter],()=>{o()}),c.watch(()=>n.converterOptions,()=>{o()},{deep:!0}),{timeago:r,updateTimer:a}},render(){return c.h("timeago",{attrs:{datetime:new Date(this.datetime).toISOString(),title:typeof this.title=="string"?this.title:this.title===!1?null:this.timeago}},[this.timeago])}})};var Ge=(e,t)=>{if(e.config.globalProperties.$timeago)return;Number(e.version.split(".")[0])<3&&console.warn("[vue-timeago3] This plugin requires at least Vue version 3.0");const a=Ze(t);e.component(a.name,a)};v.default=Ge,Object.defineProperty(v,"__esModule",{value:!0}),v[Symbol.toStringTag]="Module"});
{
"name": "vue-timeago3",
"version": "2.1.0",
"version": "2.1.2",
"files": [

@@ -9,2 +9,3 @@ "dist"

"module": "./dist/vue-timeago.es.js",
"typings": "./dist_types/**/*.d.ts",
"exports": {

@@ -37,11 +38,14 @@ ".": {

"scripts": {
"dev": " vite build && npm --prefix ./dist pack && npm --prefix examples run dev",
"build": "vue-tsc --noEmit && vite build",
"dev": "vite build && npm --prefix ./dist pack && npm --prefix examples run dev",
"build": "vue-tsc --declaration --emitDeclarationOnly && vite build",
"serve": "vite preview",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:serve": "vitepress serve docs"
"docs:serve": "vitepress serve docs",
"test": "jest --config jest.config.ts",
"lint": "eslint src --ext .ts",
"release": "release-it"
},
"dependencies": {
"date-fns": "^2.26.0"
"date-fns": "^2.27.0"
},

@@ -52,17 +56,24 @@ "peerDependencies": {

"devDependencies": {
"@types/node": "^16.11.10",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"@release-it/conventional-changelog": "^3.3.0",
"@types/jest": "^27.0.3",
"@types/node": "^16.11.11",
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
"@vitejs/plugin-vue": "^1.10.1",
"@vue/compiler-sfc": "^3.2.23",
"@vue/test-utils": "^2.0.0-rc.17",
"eslint": "^8.3.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-vue": "^8.1.1",
"jest": "^27.4.2",
"prettier": "2.5.0",
"release-it": "^14.11.8",
"ts-jest": "^27.0.7",
"ts-node": "^10.4.0",
"typescript": "^4.5.2",
"vite": "^2.6.14",
"vitepress": "^0.20.1",
"vue-eslint-parser": "^8.0.1",
"vue-tsc": "^0.29.7",
"vitepress": "^0.20.1"
"vue-tsc": "^0.29.8"
}
}

@@ -1,2 +0,3 @@

# ⏳ vue-timeago3 ![Vue version](https://img.shields.io/badge/vue-3.2.6-brightgreen.svg) ![date-fns version](https://img.shields.io/npm/dependency-version/vue-timeago3/date-fns) [![NPM version](https://img.shields.io/npm/v/vue-timeago3.svg)](https://npmjs.com/package/vue-timeago3) [![NPM downloads](https://img.shields.io/npm/dm/vue-timeago3.svg)](https://npmjs.com/package/vue-timeago3) ![size](https://img.shields.io/bundlephobia/min/vue-timeago3) [![vue-timeago3](https://circleci.com/gh/MrDeerly/vue-timeago3.svg?style=svg)](https://circleci.com/gh/MrDeerly/vue-timeago3)
# ⏳ vue-timeago3
[![NPM version](https://img.shields.io/npm/v/vue-timeago3.svg?label=Version&color=brightgreen&logo=npm)](https://npmjs.com/package/vue-timeago3) [![NPM downloads](https://img.shields.io/npm/dm/vue-timeago3.svg?label=Downloads&logo=npm)](https://npmjs.com/package/vue-timeago3) ![code-coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/MrDeerly/51a8c6c4f125bd6ec25a14a6f12e28bc/raw/vue-timeago3_coverage.json) [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2FMrDeerly%2Fvue-timeago3%2Fbadge%3Fref%3Dmaster&style=flat)](https://actions-badge.atrox.dev/MrDeerly/vue-timeago3/goto?ref=master) ![Vue version](https://img.shields.io/badge/vue-3.2.6-blue.svg) ![date-fns version](https://img.shields.io/npm/dependency-version/vue-timeago3/date-fns?color=blue) ![size](https://img.shields.io/bundlephobia/min/vue-timeago3)

@@ -6,2 +7,3 @@ A time ago component for Vue.js 3 based on [vue-timeago for Vue 2 by egoist](https://github.com/egoist/vue-timeago).

## Table of Contents
- [About](#sectionAbout)

@@ -14,2 +16,3 @@ - [Usage](#sectionUsage)

## About
<a name="sectionAbout"/>

@@ -21,17 +24,20 @@

| distance to now | result |
|----------------------|----------------------|
| 0 - 5 secs | less than 5 seconds ago |
| 5 - 10 secs | less than 10 seconds ago |
| 10 - 20 secs | less than 20 seconds ago |
| 20 - 40 secs | half a minute ago |
| 40 - 60 secs | less than a minute ago |
| distance to now | result |
| --------------- | ------------------------ |
| 0 - 5 secs | less than 5 seconds ago |
| 5 - 10 secs | less than 10 seconds ago |
| 10 - 20 secs | less than 20 seconds ago |
| 20 - 40 secs | half a minute ago |
| 40 - 60 secs | less than a minute ago |
See [date-fns/formatDistanceToNow](https://date-fns.org/v2.26.0/docs/formatDistanceToNow) for more details.
## Usage
<a name="sectionUsage"/>
**Visit the [docs](mrdeerly.github.io/vue-timeago3/) for more details!
**Visit the [docs](https://mrdeerly.github.io/vue-timeago3/) for more details!**
### Installation
<a name="sectionInstall"/>

@@ -49,2 +55,3 @@ Currently the plugin is available via NPM and Yarn. To install it use one of the two package managers.

### Register Plugin
To register the plugin simply import and register it using the new global vue3 api. As an alternative the plugin could be imported in specific components only.

@@ -67,2 +74,3 @@

#### Plugin Options
During the registration of the component you can specify a set of options, which will mutate the plugin **globally**. If you don't want to define global settings, skip this section and use props instead. To use options, simply pass them during the registration as an object:

@@ -82,4 +90,4 @@

}
}
}
app.use(timeago, timeagoOptions) // register timeago with options

@@ -89,12 +97,14 @@ ...

```
As of version 1.0.0 the following options are available:
| option | type | description |
|----------------------|----------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **name** | `string` | Register the component with a custom name. Default is: `timeago` |
| **locale** | `Locale` (see [date-fns/Locale](https://date-fns.org/v2.26.0/docs/Locale)) | The ```locale``` specifies the language which is used to render the date. All available ``date-fns`` locales are supported by default. |
| **converter** | `(date, converterOptions) => string` | A **converter** that formats regular dates in `x Seconds ago`, or in `xxx` style. Check out the [default converter](ahttps://github.com/MrDeerly/vue-timeago3/blob/master/src/defaultConverter.js) which uses [date-fns formatDistanceToNow](https://date-fns.org/v2.24.0/docs/formatDistanceToNow) |
| **converterOptions** | `Object` | Pass some extra settings to the default converter mentioned above. It supports the main options of `date-fns`, namingly: <br/><br/> `includeSeconds` - `boolean` - distances less than a minute are more detailed </br> `addSuffix` - `boolean` - results specifies if now is earlier or later than the date passed |
As of version 1.0.0 the following options are available:
| option | type | description |
| -------------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **name** | `string` | Register the component with a custom name. Default is: `timeago` |
| **locale** | `Locale` (see [date-fns/Locale](https://date-fns.org/v2.26.0/docs/Locale)) | The `locale` specifies the language which is used to render the date. All available `date-fns` locales are supported by default. |
| **converter** | `(date, converterOptions) => string` | A **converter** that formats regular dates in `x Seconds ago`, or in `xxx` style. Check out the [default converter](ahttps://github.com/MrDeerly/vue-timeago3/blob/master/src/defaultConverter.js) which uses [date-fns formatDistanceToNow](https://date-fns.org/v2.24.0/docs/formatDistanceToNow) |
| **converterOptions** | `Object` | Pass some extra settings to the default converter mentioned above. It supports the main options of `date-fns`, namingly: <br/><br/> `includeSeconds` - `boolean` - distances less than a minute are more detailed </br> `addSuffix` - `boolean` - results specifies if now is earlier or later than the date passed |
### Component
<a name="sectionComponent"/>

@@ -104,3 +114,4 @@

**Basic usage**:
**Basic usage**:
```jsx

@@ -121,10 +132,12 @@ <template>

```
#### Props
Instead of configurating the plugin during the registration, you can also configuate the component via `props`.
| property | type | required | default | description |
| property | type | required | default | description |
|----------------------|---------------------------------------------|--------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **datetime** | `string \| Date \| number` | :heavy_check_mark: | | The `datetime` used to calculate the "time ago" |
| **autoUpdate** | `number \| boolean` | :x: | `false` | The period of time to update the component, **in seconds**. <br/> This can be omitted by setting it to `0` or `false`. <br/> <br/> The default value for `true` is `60`(seconds). Instead of passing `true` you can also pass a custom time. |
| **locale** | `Locale` (see [date-fns/Locale](https://date-fns.org/v2.26.0/docs/Locale)) | The ```locale``` specifies the language which is used to render the date. All available ``date-fns`` locales are supported by default. |
| **converter** | `date, converterOptions) => string` | :x: | | See plugin options above |
| **converterOptions** | `Object` | :x: | | See plugin options above |
| **datetime** | `string \| Date \| number` | :heavy_check_mark: | | The `datetime` used to calculate the "time ago" |
| **autoUpdate** | `number \| boolean` | :x: | `false` | The period of time to update the component, **in seconds**. <br/> This can be omitted by setting it to `0` or `false`. <br/> <br/> The default value for `true` is `60`(seconds). Instead of passing `true` you can also pass a custom time. |
| **locale** | `Locale` (see [date-fns/Locale](https://date-fns.org/v2.26.0/docs/Locale)) | :x: | `en` | The `locale` specifies the language which is used to render the date. All available `date-fns` locales are supported by default. |
| **converter** | `date, converterOptions) => string` | :x: | | See plugin options above |
| **converterOptions** | `Object` | :x: | | See plugin options above |
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc