Skip to content

A library useful for creating fuzzy timestamps. (e.g. "5 minutes ago")

License

Notifications You must be signed in to change notification settings

larvalabs/timeago.dart

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

timeago

This fork simply removes deferred library loading to make it compatible with Flutter's hot reloading feature.

A library useful for creating fuzzy timestamps. (e.g. "5 minutes ago")

Pub

Build Status

Usage

import 'package:timeago/timeago.dart';

main() async {
    TimeAgo ta = new TimeAgo();
    final fifteenAgo = new DateTime.now().subtract(new Duration(minutes: 15));
    final fifteenFromNow = new DateTime.now().add(new Duration(minutes: 15));

    print(ta.format(fifteenAgo)); // 15 minutes ago
    print(ta.format(fifteenFromNow, until: true)); // 15 minutes from now

    // There's also a shorthand for a default time ago object
    print(timeAgo(new DateTime.now())); // just a moment ago


    // Load locale messages, only need to do this once per locale
    await TimeAgo.initializeLocale("es");

    // Change locale
    ta.locale = 'es';

    print(ta.format(fifteenAgo)); // hace 15 minutos
    print(ta.format(fifteenFromNow, until: true)); // dentro de 15 minutos

}

Live Demo

Here

To do

  • Add more locales

Features and bugs

Please file feature requests and bugs at the issue tracker.

About

A library useful for creating fuzzy timestamps. (e.g. "5 minutes ago")

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 93.0%
  • HTML 7.0%