-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #177 feat: add "duration" formatter (kbond)
This PR was merged into the 2.x-dev branch. Discussion ---------- feat: add "duration" formatter I have a requirement to use the `Helper::formatDuration()` from `symfony/console` in twig templates. I thought this bundle would be a good place for this. Copied much of the code from `symfony/console` and added translations. I'll leave to others to add translations for other locales. ```twig {{ 0|duration }} {# < 1 sec #} {{ 1|duration }} {# 1 sec #} {{ 56|duration }} {# 56 secs #} {{ 60|duration }} {# 1 min #} ``` Should I update the changelog? For the docs, we should perhaps re-jig them a bit as it says _This bundle does one simple job_ - not anymore if this PR is merged. Commits ------- 22e7ca8 feat: add "duration" formatter
- Loading branch information
Showing
7 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
Yesterday: {{ yesterday|ago }} | ||
Now: {{ date()|time_diff }} | ||
|
||
Zero: {{ 0|duration }} | ||
Less than a second: {{ 0.1|duration }} | ||
One second: {{ 1|duration }} | ||
Multiple seconds: {{ 59|duration }} | ||
One minute: {{ 60|duration }} | ||
Multiple minutes: {{ 3599|duration }} | ||
One hour: {{ 3600|duration }} | ||
Multiple hours: {{ 86399|duration }} | ||
One day: {{ 86400|duration }} | ||
Multiple days: {{ 8554100|duration }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters