0 purchases
whenwas
Whenwas #
Library to calculate how many years, months, days, ... ago a given DateTime is.
Usage #
import 'package:whenwas/whenwas.dart';
main() {
int year = 2000;
var date = DateTime(year);
// x years ago
print(When(date));
// in case you want a custom format:
var time = When(date).toTime();
if (time.unit == TimeUnit.YEAR) {
// x years ago in Spanish
print('Hace ${time.amount} aƱos')
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.