Skip to content

Add Somoy::diff_for_humans() for relative time strings - #7

Merged
ahamed merged 2 commits into
themeum:mainfrom
ashraful1971:feat/somoy-diff-for-humans
Aug 26, 2026
Merged

Add Somoy::diff_for_humans() for relative time strings#7
ahamed merged 2 commits into
themeum:mainfrom
ashraful1971:feat/somoy-diff-for-humans

Conversation

@ashraful1971

Copy link
Copy Markdown
Contributor

Returns strings like "5 minutes ago" and "in 3 hours" using the largest applicable unit (year down to second), with the matching signature added to SomoyInterface.

Returns strings like "5 minutes ago" and "in 3 hours" using the largest
applicable unit (year down to second), with the matching signature added
to SomoyInterface.
@ashraful1971
ashraful1971 force-pushed the feat/somoy-diff-for-humans branch from ce8b595 to d836bc9 Compare August 26, 2026 09:37
Adds $syntax (ago/from-now, before/after, or absolute), $short unit
abbreviations, $parts to join multiple units, and an $options bitmask
(NO_ZERO_DIFF, JUST_NOW, ONE_DAY_WORDS, TWO_DAY_WORDS,
SEQUENTIAL_PARTS_ONLY) to diff_for_humans(), verified against Carbon's
actual source. Two deliberate deviations, documented on the method:
$syntax always defaults to relative-to-now wording regardless of
whether $other is passed (Carbon silently switches to before/after in
that case), and Carbon's ROUND/FLOOR/CEIL rounding cascade is not
implemented.
@ahamed
ahamed merged commit fb4e80a into themeum:main Aug 26, 2026
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