@@ -83,6 +83,38 @@ Distances less than a minute are more detailed.
8383<span x-data =" { date: new Date() }" x-timeago.seconds =" date" ></span >
8484```
8585
86+ ### Strict
87+
88+ If you do not want the "about [ diff] " or "less than [ diff] " prefixes, you can use the ` x-timeago.strict ` modifier.
89+
90+ ``` html
91+ <span x-data =" { date: new Date() }" x-timeago.strict =" date" ></span >
92+ ```
93+
94+ #### Strict options
95+
96+ The strict mode comes with its own set of modifiers for controlling the output.
97+
98+ ##### Force unit
99+
100+ Use the ` x-timeago.strict.unit.[unit] ` modifier with one of the following units to force the unit in the output.
101+
102+ - ` second ` (e.g. ` x-timeago.strict.unit.second ` )
103+ - ` minute ` (e.g. ` x-timeago.strict.unit.minute ` )
104+ - ` hour ` (e.g. ` x-timeago.strict.unit.hour ` )
105+ - ` day ` (e.g. ` x-timeago.strict.unit.day ` )
106+ - ` month ` (e.g. ` x-timeago.strict.unit.month ` )
107+ - ` year ` (e.g. ` x-timeago.strict.unit.year ` )
108+
109+ ##### Adjust rounding method
110+
111+ By default, the values are rounded using the ` Math.round ` algorithm. If you would like to adjust this, use
112+ the ` x-timeago.rounding.[method] ` modifier with one of the following methods:
113+
114+ - ` floor ` (e.g. ` x-timeago.strict.rounding.floor ` )
115+ - ` ceil ` (e.g. ` x-timeago.strict.rounding.ceil ` )
116+ - ` floor ` (e.g. ` x-timeago.strict.rounding.round ` )
117+
86118### Magic function
87119
88120As of version 1.3.0 of this package a ` $timeago ` magic function is included which will return the human-readable
@@ -113,14 +145,40 @@ function.
113145<span x-data =" { date: new Date() }" x-text =" $timeago(date, null, true)" ></span >
114146```
115147
148+ #### Strict
149+
150+ If you do not want the "about [ diff] " or "less than [ diff] " prefixes, you can use the fourth parameter to provide the "
151+ strict" options.
152+
153+ ##### Default
154+
155+ ``` html
156+ <span x-data =" { date: new Date() }"
157+ x-text =" $timeago(date, null, null, { strict: true })" ></span >
158+ ```
159+
160+ ##### Unit
161+
162+ ``` html
163+ <span x-data =" { date: new Date() }"
164+ x-text =" $timeago(date, null, null, { strict: true, unit: 'second' })" ></span >
165+ ```
166+
167+ ##### Rounding method
168+
169+ ``` html
170+ <span x-data =" { date: new Date() }"
171+ x-text =" $timeago(date, null, null, { strict: true, roundingMethod: 'floor' })" ></span >
172+ ```
173+
116174### Other locales
117175
118176If you are using the ` npm ` installation method for this package or the ESM distribution, you can use the
119177` TimeAgo.configure() ` method to provide a different locale from ` date-fns ` .
120178
121179``` javascript
122180import TimeAgo from ' @marcreichel/alpine-timeago' ;
123- import { de } from ' date-fns/locale' ;
181+ import {de } from ' date-fns/locale' ;
124182
125183Alpine .plugin (TimeAgo .configure ({
126184 locale: de,
0 commit comments