timeago.dart
timeago.dart copied to clipboard
Add clock offset
This library is working great for me, but I have an idea for a small improvement. In my case I want to use it on timestamps from a server. There's a risk that the client's clock diverges from the server timestamps and shows incorrect values.
I am able to get an estimate on how much the server clock differs from the client clock.
Suggested solution: add a parameter clockOffset
that takes this difference either in milliseconds or as a Duration
, and uses it when calculating how long ago something happened.
I initially thought that this was what the clock
parameter did, but it seems like that one just sends in a fixed time. Another solution would be to change the clock
to accept a lambda instead to be called every time it needs the current time, that might be more flexible.