11# timeago  
22
3- A  library useful for creating fuzzy timestamps. (e.g. "5 minutes  ago") 
3+ ` timeago `  is a dart  library that converts a date into a humanized text. Instead of showing a date   ` 2020-12-12 18:30 `   with  ` timeago `  you can display something like  ` "now", "an hour  ago", "~1y", etc ` 
44
55|  timeago         |  [ ![ pub package] ( https://img.shields.io/pub/v/timeago.svg?label=timeago&color=blue )] ( https://pub.dartlang.org/packages/timeago )                          |  core library    | 
66| -----------------| --------------------------------------------------------------------------------------------------------------------------------------------------------| -----------------| 
@@ -26,9 +26,10 @@ main() {
2626``` 
2727
2828##### IMPORTANT  
29- timeago library ** ONLY**  includes ` en `  and ` es `  messages loadded by default. 
3029
31- To add more of the supported languages use ` timeago.setLocaleMessages(..) ` . See [ locale messages] ( lib/source/messages ) .
30+ timeago library ** ONLY**  includes ` en `  and ` es `  messages loadded by default.
31+ 
32+ To add more of the supported languages use ` timeago.setLocaleMessages(..) ` . See [ locale messages] ( packages/timeago/lib/source/messages ) .
3233
3334### Adding locales  
3435
@@ -42,56 +43,50 @@ print(timeago.format(fifteenAgo, locale: 'es')); // environ 15 minutes
4243### Overriding locales or adding custom messages  
4344
4445``` dart 
45- // Override "en" locale messages with custom messages that are more precise 
46+ // Override "en" locale messages with custom messages that are more precise and short  
4647timeago.setLocaleMessages('en', MyCustomMessages()); 
4748
4849
4950// my_custom_messages.dart 
5051class MyCustomMessages implements LookupMessages { 
51-   @override 
52-   String prefixAgo() => ''; 
53-   @override 
54-   String prefixFromNow() => ''; 
55-   @override 
56-   String suffixAgo() => ''; 
57-   @override 
58-   String suffixFromNow() => ''; 
59-   @override 
60-   String lessThanOneMinute(int seconds) => 'now'; 
61-   @override 
62-   String aboutAMinute(int minutes) => '${minutes}m'; 
63-   @override 
64-   String minutes(int minutes) => '${minutes}m'; 
65-   @override 
66-   String aboutAnHour(int minutes) => '${minutes}m'; 
67-   @override 
68-   String hours(int hours) => '${hours}h'; 
69-   @override 
70-   String aDay(int hours) => '${hours}h'; 
71-   @override 
72-   String days(int days) => '${days}d'; 
73-   @override 
74-   String aboutAMonth(int days) => '${days}d'; 
75-   @override 
76-   String months(int months) => '${months}mo'; 
77-   @override 
78-   String aboutAYear(int year) => '${year}y'; 
79-   @override 
80-   String years(int years) => '${years}y'; 
81-   @override 
82-   String wordSeparator() => ' '; 
52+   @override String prefixAgo() => ''; 
53+   @override String prefixFromNow() => ''; 
54+   @override String suffixAgo() => ''; 
55+   @override String suffixFromNow() => ''; 
56+   @override String lessThanOneMinute(int seconds) => 'now'; 
57+   @override String aboutAMinute(int minutes) => '${minutes}m'; 
58+   @override String minutes(int minutes) => '${minutes}m'; 
59+   @override String aboutAnHour(int minutes) => '${minutes}m'; 
60+   @override String hours(int hours) => '${hours}h'; 
61+   @override String aDay(int hours) => '${hours}h'; 
62+   @override String days(int days) => '${days}d'; 
63+   @override String aboutAMonth(int days) => '${days}d'; 
64+   @override String months(int months) => '${months}mo'; 
65+   @override String aboutAYear(int year) => '${year}y'; 
66+   @override String years(int years) => '${years}y'; 
67+   @override String wordSeparator() => ' '; 
8368} 
69+ 
8470``` 
8571
86- --- 
72+ ## Scope  
73+ 
74+ While there are many request for adding more complex functionality I want keep this library as simple as possible to allow minimal maintenance.
8775
88- ## timeago_flutter widgets  
76+ The focus of this library should be
77+ 
78+ 1 .  Provide a single ` format `  function that transforms a ` date `  to a humanized value
79+ 2 .  Give the abstractions for users to add their own languages or overriding them as they please
80+ 3 .  Provide languages contributed by the community so users can add them _ as they need_  we should not add all languages by default.
81+ 4 .  Library should not depend on any dependency
82+ 
83+ # timeago_flutter widgets  
8984
9085-  Timeago
9186-  TimerRefresh
9287-  TimerRefreshWidget
9388
94- ##  Local development  
89+ # Local development  
9590
96911 .  Install Melos (https://pub.dev/packages/melos ):
9792
@@ -103,6 +98,7 @@ class MyCustomMessages implements LookupMessages {
10398
104993 .  Open desired package in VSCode or Webstorm
105100
106- ###  Live Demo  
101+ # Live Demo  
107102
108103[ Here] ( http://andresaraujo.github.io/timeago.dart/ ) 
104+ 
0 commit comments