protontime 1.0.3 copy "protontime: ^1.0.3" to clipboard
protontime: ^1.0.3 copied to clipboard

A library useful for creating fuzzy timestamps. (e.g. "2 min ago")

protontime #

protontime is a dart library that converts a date into a humanized text. Instead of showing a date 2024-01-01 01:01 with protontime you can display something like "now", "5 sec ago", "an hour ago", etc

A Flutter plugin for launching a URL.

Android iOS Linux macOS Web Windows
Support SDK 16+ 12.0+ Any 10.14+ Any Windows 10+

Installation #

With Dart:

dart pub add protontime

With Flutter:

flutter pub add protontime

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  protontime: ^latest

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it #

Now in your Dart code, you can use:

import 'package:protontime/protontime.dart';

Usage #

The easiest way to use this library via top-level function humanReadableTime(date):

import 'package:protontime/protontime.dart';

main() {
    final fiveSecAgo = DateTime.now().subtract(Duration(seconds: 5)).toString();

    print(fiveSecAgo); // 2024-01-01 00:00:00.000000
    print(Protontime.format(fiveSecAgo); // 5 sec ago
}

Scope #

While there are many request for adding more complex functionality I want keep this library as simple as possible to allow minimal maintenance.

The focus of this library should be

  1. Provide a single format function that transforms a date to a humanized value
  2. Give the abstractions for users to add their own languages or overriding them as they please
  3. Provide languages contributed by the community so users can add them as they need we should not add all languages by default.
  4. Library should not depend on any dependency
2
likes
160
points
232
downloads

Publisher

verified publishernben.com.np

Weekly Downloads

A library useful for creating fuzzy timestamps. (e.g. "2 min ago")

Homepage

Topics

#time #date

Documentation

API reference

License

MIT (license)

More

Packages that depend on protontime