Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional minimumVarianceUnit to GetTimeAgo.parse for custom stopping points #37

Conversation

josephtaylor-mn
Copy link

Pull Request Checklist

What does this PR do?

This PR introduces an optional minimumVarianceUnit parameter to the GetTimeAgo.parse method, allowing users to specify a unit (seconds, minutes, hours, days) to act as a threshold. When the elapsed time is less than this threshold, the method returns “Less than [Unit]”. If the elapsed time is less than 15 seconds, it always returns “Just now”. If the parameter is not provided, the method retains its original behavior.

Checklist

Code Changes

  • I have added new features to the package (e.g., custom time thresholds, new languages, etc.)
  • I have fixed existing issues (e.g., incorrect formatting, performance bottlenecks)
  • I have improved the overall structure or optimized the codebase

Documentation

  • I have updated the README file or relevant documentation with the changes
  • I have added code usage examples or updated existing examples to reflect changes
  • I have updated the package version in the pubspec.yaml file

Testing

General Tests

  • The package correctly formats time differences into human-readable strings
  • The package supports dynamic updates (e.g., changing locales, thresholds)

Localization

  • The package supports all documented languages
  • Custom locales can be added and work as expected
  • Language fallback works correctly if a specific locale is missing

Custom Thresholds

  • Custom time thresholds are applied correctly
  • The package handles edge cases like just now, future dates, or extreme past dates

Error Handling

  • The package handles null or invalid inputs gracefully
  • Fallback behavior works for unexpected or incorrect configurations

Responsiveness

  • The package adapts to time-zone differences accurately
  • The formatting responds correctly to locale changes in the app

Performance

  • The package performs efficiently, even when processing frequent or large updates
  • Performance tests show no regressions

How did you verify your code works?

I ran manual tests to verify time formatting for different locales and thresholds

…ing points

Introduce an optional minimumVarianceUnit parameter to the GetTimeAgo.parse method, allowing users to specify a unit (seconds, minutes, hours, days) to act as a threshold. When the elapsed time is less than this threshold, the method returns “Less than [Unit]”. If the elapsed time is less than 15 seconds, it always returns “Just now”. If the parameter is not provided, the method retains its original behavior.
Copy link
Owner

@nixrajput nixrajput left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @josephtaylor-mn,

Thank you for contributing to the project.
Please write test cases or make changes to existing test cases before I merge this branch.

Regards,
Nikhil

@nixrajput
Copy link
Owner

Please fix the errors occurring during workflows too.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants