You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know we can create our own locale with strings, but it is not clear to me how I can modify this to do what I want... or if it's even possible.
const localeFunc = (number: number, index: number, totalSec: number): [string, string] => {
// number: the timeago / timein number;
// index: the index of array below;
// totalSec: total seconds between date to be formatted and today's date;
return [
['just now', 'right now'],
['%s seconds ago', 'in %s seconds'],
['1 minute ago', 'in 1 minute'],
['%s minutes ago', 'in %s minutes'],
['1 hour ago', 'in 1 hour'],
['%s hours ago', 'in %s hours'],
['1 day ago', 'in 1 day'],
['%s days ago', 'in %s days'],
['1 week ago', 'in 1 week'],
['%s weeks ago', 'in %s weeks'],
['1 month ago', 'in 1 month'],
['%s months ago', 'in %s months'],
['1 year ago', 'in 1 year'],
['%s years ago', 'in %s years']
][index];
};
// register your locale with timeago
register('my-locale', localeFunc);
// use it
format('2016-06-12', 'my-locale');
The default above will show 'just now' 10s in from the time and 'right now' 10s out from the time. How can I change this so it shows 'right now' when it is exactly 0s and uses ['%s seconds ago', 'in %s seconds'], for all other seconds up until the minute mark?
The text was updated successfully, but these errors were encountered:
I know we can create our own locale with strings, but it is not clear to me how I can modify this to do what I want... or if it's even possible.
The default above will show 'just now' 10s in from the time and 'right now' 10s out from the time. How can I change this so it shows 'right now' when it is exactly 0s and uses
['%s seconds ago', 'in %s seconds'],
for all other seconds up until the minute mark?The text was updated successfully, but these errors were encountered: