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
parsing date strings is tricky (many different formats) but converting milliseconds into the proper "scale" is very easy.
we should add an option to localize (second argument being an object with localization info), the localization scheme should support pluralization, thinking something like:
varms=1234567;// diff in millisecondsago(ms);// "20 minutes ago"// l10nvarptBr={'minutes' : {'1' : '1 minuto atrás','other' : '# minutos atrás'},'days' : {'1' : 'ontem',// yesterday'2' : 'antes de ontem',// so we can pass custom values for specific numbers'other' : '# dias atrás'},// ... weeks, months, years};ago(ms,ptBr);// "20 minutos atrás"
And if you pass a Date object it calculates the diff automatically.
varsomeDate=newDate(2011,01,01);ago(someDate);// "1 year ago"
I think the utility to parse a date string into a Date object should be implemented separately and inside a date package. I think the ago() method should be inside the time package.
It would be nice to have a function that receives a date object or a valid date string and converts it to a more human readable date:
Some libraries that implement this feature:
The text was updated successfully, but these errors were encountered: