0 purchases
time elapsed
TimeElapsed #
This package provides a way to facility how you getting elapsed time from a DateTime data. More applied to check how long from now an event happened.
Default: #
It return elapsed time by Weeks, Days, Hours and Minutes
How to use: #
The package has a two method to get date time elapsed: fromDateStr() and fromDateTime()
You can also use a dynamic parsin method: elapsedTimeDynamic()
You can pass it as String or DateTime type:
String timeString = "2020-04-19 03:48:57.063773"; // set a String type var with Date sample
DateTime timeDate = DateTime.parse("2020-04-19 03:48:57.063773"); // set a DateTime var sample
// to calculate from String
String timeStamp = TimeElapsed.fromDateStr(timeString); // returns 8w (cos now days:2020-06-19)
// to calculate from DateTime
String timeStamp = TimeElapsed.fromDateTime(timeDate); // returns 8w (cos now days: 2020-06-19)
copied to clipboard
If you do not know what type data is, (String or DateTime):
// to calculate from both, DateTime or String
String timeStamp = TimeElapsed.elapsedTimeDynamic(timeDate); // returns 8w (cos now days: 2020-06-19)
copied to clipboard
both methods will return the time elapsed as String
Using Custom Markers for Time (Days, weeks, hours etc...) #
To adds a custom texts or change the text near to period elapsed you can use .toCustomTimeElapsed() method. This method receives an object from CustomTimeElapsed class which contains all period we use.
// custom Time String marker
final customDate = CustomTimeElapsed(
minutes: 'minutos',
hours: 'horas',
days: 'dias',
now: 'agora',
seconds: 'segundos',
weeks: 'semanas',
);
// Widget that output "76 semanas" instead of "76w"
Text(TimeElapsed.fromDateStr(_timeString).toCustomTimeElapsed(customDate))
copied to clipboard
_ #
In another hand, if you prefer, you can pass as params too using .toCustomWDHMS().
toCustomWDHMS(
minutes: 'minutos',
hours: 'horas',
days: 'dias',
now: 'agora',
seconds: 'segundos',
weeks: 'semanas',
)
copied to clipboard
Example: #
This example app shows all implementations
App shot
Have a Nice Code!
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.