Skip to content

Latest commit

 

History

History
50 lines (31 loc) · 1.49 KB

README.md

File metadata and controls

50 lines (31 loc) · 1.49 KB

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.