Skip to content

Add support for abbreviated/short relative time format #183

Description

@yeldar-nurpeissov

Problem

The library currently formats relative time using full unit names, for example:

  • 3 hours ago

  • 5 minutes ago

  • 2 days ago

In some UI contexts (mobile apps, compact lists, feeds, badges, etc.), a shorter representation would be preferable.

Proposed Solution

Add an option to format relative time using abbreviated units.

Example:

Current | Short Format
------------| -------
3 hours ago | 3 h ago
5 minutes ago | 5 min ago
2 days ago | 2 d ago
1 week ago | 1 wk ago

Possible API examples:

HumanReadable.timeAgo(now - 134.minutes, style = TimeStyle.SHORT)

Use Cases

  • Mobile applications with limited screen space

  • Lists and feeds with many timestamps

  • Compact UI components such as chips, cards, and notifications

Expected Output

3 h ago
15 min ago
2 d ago
1 wk ago
3 mo ago
1 yr ago

Additional Notes

The default behavior could remain unchanged to avoid breaking existing users, while the short format is exposed as an optional style/configuration.

The abbreviated units should ideally be localizable in the same way as the existing long-form units.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions