Skip to content

[Bug]: Future dates parsed to past #52

@uwemeier-sclable

Description

@uwemeier-sclable

Contact Details

No response

What happened?

Expected behaviour

When providing a date in the future, there should be an indication, that the date is in the future (e.g. "in 20 seconds")

Actual behaviour

When providing a date in the future, the absolute value of the time difference is used, resulting in an incorrect representation, that always talks about the time being in the past

Steps to reproduce

  1. Run this code:
 DateTime futureTime = DateTime.now().add(const Duration(seconds: 20));
 String futureTimeString = GetTimeAgo.parse(futureTime);
 print('Future time string: $futureTimeString');
  1. See the output: I/flutter (17717): Future time string: 19 seconds ago

Technical Details

  1. extend Messages with a prefixFromNow() and `suffixFromNow()
  2. in _get_time_ago.dart use either *FromNow() or *Ago() depending on whether dateTime is after now or not.

Version

^2.3.2

What devices are you seeing the problem on?

Android, iPhone, Windows, Mac, Linux

OS

Android 12

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions