Giter Site home page Giter Site logo

knptimebundle's Introduction

knplabs/knp-time-bundle

Friendly ago/until dates ("5 minutes ago" or "in 5 minutes") and durations ("2 mins")!

Last edited: {{ post.updatedAt|time_diff }} <!-- Last edited: 1 week ago -->

Event date: {{ event.date|time_diff }} <!-- Event date: in two weeks -->

Read time: {{ post.readTimeInSeconds|duration }} <!-- Read time: 2 minutes -->

Age: {{ user.birthdate|age }} <!-- Age: 30 years old -->

Want to see it used in a screencast 🎥? Check out SymfonyCasts: https://symfonycasts.com/screencast/symfony-doctrine/ago

The formatted date/duration can be translated into any language, and many are supported out of the box.

Installation

Use Composer to install the library:

composer require knplabs/knp-time-bundle

Woo! You did it! Assuming your project uses Symfony Flex, the bundle should be configured and ready to go. If not, you can enable Knp\Bundle\TimeBundle\KnpTimeBundle manually.

Usage

Twig

Time formatting:

{{ someDateTimeVariable|time_diff }} {# 2 weeks ago #}

{# |ago is an alias for |time_diff #}
{{ someDateTimeVariable|ago }} {# 1 second ago #}

{# ... or use the equivalent function: #}
{{ time_diff(someDateTimeVariable) }} {# in 2 months #}

Note: the time_diff filter/function and ago alias works fine for dates in the future, too.

Duration formatting:

{{ someDurationInSeconds|duration }} {# 2 minutes #}

Age formatting:

{# with filter: #}
Age: {{ user.birthdate|age }} {# Age: 30 years old #}

{# ... or use the equivalent function: #}
Age: {{ age(user.birthdate) }} {# Age: 30 years old #}

Service

You can also format dates and durations in your services/controllers by autowiring/injecting the Knp\Bundle\TimeBundle\DateTimeFormatter service:

use Knp\Bundle\TimeBundle\DateTimeFormatter;
// ...

public function yourAction(DateTimeFormatter $dateTimeFormatter)
{
    $someDate = new \DateTimeImmutable('-2 years'); // or $entity->publishedDate()
    $toDate = new \DateTimeImmutable('now');

    $agoTime = $dateTimeFormatter->formatDiff($someDate, $toDate); // $toDate parameter is optional and defaults to "now"

    $readTime = $dateTimeFormatter->formatDuration(64); // or $entity->readTimeInSeconds()

    $ageTime = $dateTimeFormatter->formatAge($someDate, $toDate); // $toDate parameter is optional and defaults to "now"

    return $this->json([
        //  ...
        'published_at' => $agoTime, // 2 years ago
        'read_time' => $readTime, // 1 minute
        // ...
    ]);
}

Controlling the Translation Locale

The bundle will automatically use the current locale when translating the "time_diff" ("ago") and "duration" messages. However, you can override the locale:

{{ someDateTimeVariable|time_diff(locale='es') }}

{{ someDurationInSeconds|duration(locale='es') }}

{{ someDateTimeVariable|age(locale='es') }}

Tests

If you want to run tests, please check that you have installed dev dependencies.

./vendor/bin/phpunit

Maintainers

Anyone can contribute to this repository (and it's warmly welcomed!). The following people maintain and can merge into this library:

knptimebundle's People

Contributors

ahaaje avatar akovalyov avatar aleixfargas avatar behram avatar chris8934 avatar cvele avatar docteurklein avatar everzet avatar gimler avatar herzult avatar imanalopher avatar itavero avatar jpgiroux avatar jrushlow avatar kbond avatar l3pp4rd avatar m-vo avatar mbontemps avatar michalkurzeja avatar nicolasnssm avatar ornicar avatar pierstoval avatar pilot avatar relo-san avatar seb-jean avatar stloyd avatar thomaslandauer avatar thvd avatar umpirsky avatar weaverryan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

knptimebundle's Issues

Bug on latest version of twig bundle

On latest version of twig bundle an error occurred:

Attempted to load class "Twig_Extension" from the global namespace.
!! Did you forget a "use" statement?

Using the "Twig_Extension" class is deprecated since Twig version 2.7

You can check it if install Symfony 5 and then try to install KnpTimeBundle

weird error Twig Critical

Is this a problem of KnpTimeBundle?

[2012-06-30 12:56:00] request.CRITICAL: Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("Unable to choose a translation fo
r "wczoraj|%count% dni temu" with locale "pl".") in "KnpBundlesBundle::layout.html.twig" at line 55. (uncaught exception) at app/cache/prod/classes.php line 8510 [] []

could you please check?

Filter ago or time_diff cannot be called with apply_filter

Hello!

I've just updated to 2.2 since 1.20 and i noticed that i cant call the filters with the apply_filter
Results in this error:

An exception has been thrown during the rendering of a template ("call_user_func(): Argument #1 ($callback) must be a valid callback, non-static method Knp\Bundle\TimeBundle\DateTimeFormatter::formatDiff() cannot be called statically").

Steps to reproduce:

// test.html.twig

{% set date = date() %} // or any date from controller, db, etc
{{ date|ago }} //works
{{ date|time_diff }} //works

{{date|apply_filter('time_diff')}} //doesn't work
{{date|apply_filter('ago')}} //doesn't work

Im required to apply_filter because 'ago' is being set dynamically. Sure, i can just put an if statement and call the filter directly, but im guessing this is a compatibility error.

Any thoughts? Thanks!

feat: add "age" formatter

Hello,

Do you think it would be nice to add a feature to get the age?

For example :

{# with filter: #}
Age: {{ user.birthdate|age }} <!-- Age: 30 years old -->

{# ... or use the equivalent function: #}
Age: {{ age(user.birthdate) }} <!-- Age: 30 years old -->

Bug - wrong translation files

Hello,

in my translation files there is following mistake:

<trans-unit id="1">
                <source>diff.ago.year</source>
                <target>vor einem Jahr|vor %count% Jahren</target>
</trans-unit>

So I get results like this: vor einer Minute|vor 56 Minuten (one minute ago|56 minutes ago)

This bug is in all translations files and for all translations.

Pluralization crashing on Symfony 3.4 with 1.9 release

Hi,

Release 1.9 is making translator's pluralization crash with Symfony 3.4. It shows both singular and plural 1 year ago|4 years ago options instead of plural only (in my case 4 years ago). See screenshot below.

image

I had to downgrade to version 1.8 to make it work.

cannot install in symfony version 3.3.6

$ composer require knplabs/knp-time-bundle
Using version ^1.7 for knplabs/knp-time-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files

Incenteev\ParameterHandler\ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache

[Symfony\Component\Filesystem\Exception\IOException]
Failed to remove directory "C:\xampp\htdocs\coi\var\cache\de~\profiler\c0":
.

cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--]

Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception

Installation failed, reverting ./composer.json to its original content.

[RuntimeException]
An error occurred when executing the ""cache:clear --no-warmup"" command:

[Symfony\Component\Filesystem\Exception\IOException]

Failed to remove directory "C:\xampp\htdocs\coi\var\cache\de~\profiler\c0

":
.

cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet]
[-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interact
ion] [-e|--env ENV] [--no-debug] [--]

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] []...

Add DateTimeFormatterInterface

Add the interface so we can inject a different formatter. We want to use differencing without having to turn on translation. Currently you inject a concrete instance of DateTimeFormatter into TimeHelper using the container.

symfony/translation dependency v3.4

I see that "symfony/translation": "~3.4 dependency was removed in the f3d0151 commit.

It looks like it was unintentional given adjacent dependencies still support 3.4 branch of the symfony.

Would it be possible to have it back?

New Feature: Translations in catalan

I've tried to do a pull request, but I always get permission denied (it's my very first time contributing, so maybe I am doing something wrong), so I open this issue to share with all of you the catalan translations for this bundle:

<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file source-language="ca" datatype="plaintext" original="file.ext">
        <body>
            <trans-unit id="1">
                <source>diff.ago.year</source>
                <target>fa 1 any|fa %count% anys</target>
            </trans-unit>
            <trans-unit id="2">
                <source>diff.ago.month</source>
                <target>fa 1 mes|fa %count% mesos</target>
            </trans-unit>
            <trans-unit id="3">
                <source>diff.ago.day</source>
                <target>fa 1 dia|fa %count% dies</target>
            </trans-unit>
            <trans-unit id="4">
                <source>diff.ago.hour</source>
                <target>fa 1 hora|fa %count% hores</target>
            </trans-unit>
            <trans-unit id="5">
                <source>diff.ago.minute</source>
                <target>fa 1 minut|fa %count% minuts</target>
            </trans-unit>
            <trans-unit id="6">
                <source>diff.ago.second</source>
                <target>fa 1 segon|fa %count% segons</target>
            </trans-unit>
            <trans-unit id="7">
                <source>diff.empty</source>
                <target>ara</target>
            </trans-unit>
            <trans-unit id="8">
                <source>diff.in.second</source>
                <target>d'aquí 1 segon|d'aquí %count% segons</target>
            </trans-unit>
            <trans-unit id="9">
                <source>diff.in.hour</source>
                <target>d'aquí 1 hora|d'aquí %count% hores</target>
            </trans-unit>
            <trans-unit id="10">
                <source>diff.in.minute</source>
                <target>d'aquí 1 minut|d'aquí %count% minuts</target>
            </trans-unit>
            <trans-unit id="11">
                <source>diff.in.day</source>
                <target>d'aquí 1 dia|d'aquí %count% dies</target>
            </trans-unit>
            <trans-unit id="12">
                <source>diff.in.month</source>
                <target>d'aquí 1 mes|d'aquí %count% mesos</target>
            </trans-unit>
            <trans-unit id="13">
                <source>diff.in.year</source>
                <target>d'aquí 1 any|d'aquí %count% anys</target>
            </trans-unit>
        </body>
    </file>
</xliff>

Wrong date and time

Hello devs! Someone ever come across this issue?
I am having diff.ago.day or diff.ago.time displayed each time.
I have version "knplabs/knp-time-bundle": "^2.2" running on Symfony 6.3
I have removed and reinstall, dump translations and cleared my cache and everything I can think of.
Thanks for the help.

Allow Symfony 5

Symfony5 is out, not sure what's needed to update this bundle. My attempt to simply bump the dependencies didn't work, can we drop PHP5 support?

Also, I think symfony/templating has been deprecated in favor of twig/twig, but I'm not sure how to provide BC for this.

Translations of output

Good Day,
How can I translate my 'ago' output in another language than English?

I'm an entry-level user/

Rgds

Age translations

We would need the translations for the formatted age (#192)

  • ar
  • bg
  • bs_Latn_BA
  • ca
  • cs
  • da
  • de : #194
  • en
  • eo
  • es
  • eu
  • fi
  • fr
  • hr_HR
  • hu
  • id
  • it
  • ja
  • ky
  • lt
  • nb
  • nl
  • nn
  • pl
  • pt_BR
  • pt_PT
  • pt
  • ro
  • ru
  • sk
  • sl
  • sr_Latin
  • sv
  • th
  • tr
  • uk
  • vi
  • zh_CN
  • zh_HK
  • zh_TW
  • zh

Required translation keys:

<trans-unit id="19">
<source>age</source>
<target>1 an|%count% ans</target>
</trans-unit>

Symfony4 support

composer require knplabs/knp-time-bundle outputs error:

  • knplabs/knp-time-bundle v1.2 requires symfony/framework-bundle >=2.0,<2.4-dev -> satisfiable by symfony/framework-bundle[2.0.x-dev, 2.1.x-dev, 2.2.x-dev, 2.3.x-dev].

Adding support for Syfmony4 would be nice!

Pull requests waiting for merge, maybe addressing this issue?
#103

Allow specify precision

It would be great if we could change precision of displayed diff. For example, currently date("-34 days")|ago shows month ago. But maybe it could be some parameter to ago to make this more precise, showing 34 days ago, without rounding it?

Wrong "ago" result

Hello KnpLabs, I am happily using the current version of your bundle.

If I use the ago function today ("09/16/2023") for the date "02/27/1900", the result is: 3 years ago.
Is it possible to display "older" data correctly?

Duration translations

Meta issue to track formatted duration (#177) translations.

  • ar
  • bg
  • bs_Latn_BA
  • ca
  • cs
  • da
  • de #189
  • en
  • eo
  • es #188
  • eu
  • fi
  • fr #187
  • hr_HR
  • hu
  • id
  • it
  • ja
  • ky
  • lt
  • nb #184
  • nl #191
  • nn
  • pl #193
  • pt_BR
  • pt_PT
  • pt
  • ro
  • ru #185
  • sk
  • sl
  • sr_Latin
  • sv
  • th
  • tr
  • uk
  • vi
  • zh_CN
  • zh_HK
  • zh_TW
  • zh

Required translation keys:

<trans-unit id="14">
<source>duration.second</source>
<target>1 second|%count% seconds</target>
</trans-unit>
<trans-unit id="15">
<source>duration.minute</source>
<target>1 minute|%count% minutes</target>
</trans-unit>
<trans-unit id="16">
<source>duration.hour</source>
<target>1 hour|%count% hours</target>
</trans-unit>
<trans-unit id="17">
<source>duration.day</source>
<target>1 day|%count% days</target>
</trans-unit>
<trans-unit id="18">
<source>duration.none</source>
<target>&lt; 1 second</target>
</trans-unit>

Feature request: specify the locale

Hi,
I have look on how to solve this problem for a bit now and believe that it is not possible with the current code.

I need to send a batch of emails to different users with different locales. In these emails, I want to use the ago function. It seems that since I use it in the console environment, the translator it set on the default_locale witch does not match the locale of some users.

Thank you!

Ability to wrap in <abbr> tag

Hey guys,

Do you think it would be possible to have the ability to wrap the time diff in an <abbr> tag?

So, something like

We shipped your order {{ order.shippedAt|ago }}.

would produce:

We shipped your order <abbr title="2015-03-04 10:00:00">2 months ago</abbr>

Not sure if this would be controlled by config or if there'd be a separate filter (ago_abbr).

Let me know what you think.

Cheers,

Tom

Documentation

Hello @weaverryan !

I hope you are doing fine ! 🌻

We are trying to uniform documentation on our public repositories adding code of conducts and contributing guidelines (you can check Snappy repository as an example CODE_OF_CONDUCT.md and CONTRIBUTING.md).

Do you mind if we create a PR to add them on this repository as well (the contributing guidelines will be more generic than Snappy's ones)?

Have a nice day !
Eve

cc @akovalyov @NicolasNSSM

Symfony 2.2 support

I note that there is a branch for 2.2 support. Could this be merged in to master? Also tagging a 1.0 release might be nice too.

Worng value

It's show only diff.ago.hour. translation is not included by default
translator: { fallbacks: ["%locale%"] } is activated
Symfony 3.1

Allowing TimeHelper::diff to default to NULL (from datetime|ago twig filter) shows 'in -1 years' result

Issue #103 removed a test that would prove this (failing) test with an (almost) identical DateTime (compared to time()) for the |ago filter:

public function testFormatDiffDefaultToIsNull()
{
    $from = new \DatetimeImmutable(date('Y-m-d H:i:s', time()));
    $to = new \DateTime(null);
    $this->assertEquals('diff.empty', $this->formatter->formatDiff($from, $to));
    // actually returns 'diff.in.year' - or 'in -1 years' for English translation
}

In a live code scenario it would happen like this in a twig template (here, profile->updatedAt is a simple DateTime, with seconds resolution):

{# profile.updatedAt is a simple DateTime #}
<p>Updated: {{ profile.updatedAt|ago() }}</p>

But, the ago() uses the profile.updatedAt as the first parameter. and defaults to NULL as the second, from the twig filter TimeExtension::diff() (calling TimeHelper::diff()).

TimeHelper::diff(), via getDatetimeObject(), takes the null and makes it a DateTime(), defaulting to 'now' (with microseconds since PHP7.2):

return new DateTime(null);

Hence, the test above, which if you edit a profile and immediately show the updatedAt|ago() in a twig template can show 'in -1 Year' as the result.

If the default, in getDatetimeObject() was return new DateTime(null ?? '@'.time()); solves the issue, but setting it to DateTime('now') would still fail because of the tiny difference in microseconds.

Help

I'm trying to get the ago date from my controller.php , can you explain with an exmple how do we use the helper :
if we have $date1 represent the date how do we call heplers and then call the diff function ?
tried use Knp\Bundle\TimeBundle\Templating\Helper as Helper;
$h=new Helper('Y-m-d H:i:s');
but this didnt work for me

Unusable with translator component disabled.

I am attempting to make use of the Twig ago filter in my project. However, for various reasons that are not relevant here, I have the translator component disabled. As a result, this filter (and the bundle as a whole) does not work.

I understand why this bundle uses the translator component, but that utilization should be a feature, not a prerequisite.

Any chance something will be done to change this?

Twig addExtension Uncaught Twig\Error\RuntimeError

Hi,

Maybe I'm doing something wrong, but I can't tell from the description. I add the time extension to Twig, but then I get an Uncaught Twig\Error\RuntimeError error.

$twig->addExtension(new \Knp\Bundle\TimeBundle\Twig\Extension\TimeExtension());

Uncaught Twig\Error\RuntimeError: Unable to load the "Knp\Bundle\TimeBundle\DateTimeFormatter" runtime in "_string_template

Twig 3 & SF 5 compatibility: Bug on latest master branch build & solution

Installation of the latest master branch results in the following error (Twig 3 & SF 5):

% composer require knplabs/knp-time-bundle dev-master
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "5.0.*"
Package operations: 2 installs, 0 updates, 0 removals
  - Installing symfony/templating (v5.0.2): Loading from cache
  - Installing knplabs/knp-time-bundle (dev-master ab88c33): Downloading (100%)         
Writing lock file
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Symfony operations: 1 recipe (4f0778d90f6e5ea704fa8d15747dd47c)
  - Configuring knplabs/knp-time-bundle (>=dev-master): From auto-generated recipe
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  
!!   // Clearing the cache for the dev environment with debug                       
!!   // true                                                                        
!!  
!!  16:01:05 CRITICAL  [php] Uncaught Error: Argument 1 passed to Knp\Bundle\TimeBundle\DateTimeFormatter::__construct() must be an instance of Symfony\Component\Translation\TranslatorInterface, instance of Symfony\Component\Translation\DataCollectorTranslator given, called in /Users/USER/Sites/apps/PROJECT/var/cache/dev/ContainerXX8gsrP/App_KernelDevDebugContainer.php on line 1773 ["exception" => TypeError { …}]
!!  
!!  In DateTimeFormatter.php line 17:
!!                                                                                 
!!    Argument 1 passed to Knp\Bundle\TimeBundle\DateTimeFormatter::__construct()  
!!     must be an instance of Symfony\Component\Translation\TranslatorInterface,   
!!    instance of Symfony\Component\Translation\DataCollectorTranslator given, ca  
!!    lled in /Users/USER/Sites/apps/PROJECT/var/cache/dev/  
!!    ContainerXX8gsrP/App_KernelDevDebugContainer.php on line 1773                
!!                                                                                 
!!  
!!  cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
!!  
!!  
Script @auto-scripts was called via post-update-cmd

Installation failed, reverting ./composer.json to its original content.

Solution (DateTimeFormatter.php):
Line 5 old:
use Symfony\Component\Translation\TranslatorInterface;

Line 5 new:
use Symfony\Component\Translation\DataCollectorTranslator;

Line 17 old:
public function __construct(TranslatorInterface $translator)

Line 17 new:
public function __construct(DataCollectorTranslator $translator)

Symfony 2.4 support

When adding "symfony/symfony": "~2.4", to my composer.json I get Your requirements could not be resolved to an installable set of packages.

Removing "knplabs/knp-time-bundle": "~1.2", from my composer.json file makes things install ok.

Here is the full error:

Problem 1
    - symfony/framework-bundle 2.0.7 requires symfony/translator 2.0.7 -> no matching package found.
    - Conclusion: don't install symfony/symfony 2.5.x-dev
    - Conclusion: don't install symfony/symfony 2.4.x-dev
    - Conclusion: don't install symfony/symfony v2.4.0-RC1
    - app 2.3.x-dev requires knplabs/knp-time-bundle ~1.2 -> satisfiable by knplabs/knp-time-bundle[v1.2].
    - knplabs/knp-time-bundle v1.2 requires symfony/framework-bundle >=2.0,<2.4-dev -> satisfiable by symfony/symfony[2.3.x-dev, 2.0.7, 2.0.x-dev, 2.1.x-dev, 2.2.x-dev, v2.0.10, v2.0.11, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.24, v2.0.25, v2.0.9, v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.1, v2.2.10, v2.2.2, v2.2.3, v2.2.4, v2.2.5, v2.2.6, v2.2.7, v2.2.8, v2.2.9, v2.3.0, v2.3.1, v2.3.2, v2.3.3, v2.3.4, v2.3.5, v2.3.6, v2.3.7], symfony/framework-bundle[2.0.7, 2.0.x-dev, 2.1.x-dev, 2.2.x-dev, 2.3.x-dev, v2.0.10, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.24, v2.0.25, v2.0.9, v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.1, v2.2.10, v2.2.2, v2.2.3, v2.2.4, v2.2.5, v2.2.6, v2.2.7, v2.2.8, v2.2.9, v2.3.0, v2.3.1, v2.3.2, v2.3.3, v2.3.4, v2.3.5, v2.3.6, v2.3.7].

Packagist references a commit that has been removed

Packagist currently references this commit: ad2aecd

Which right now does not appear in the repository so my guess is that it has been removed after the push. However Packagist has not taken this into account. Which is why it's impossible to install via composer right now.

That commit says that KNPLabs does not want to keep maintaining this bundle but has been removed. If the end of support is actually the case, I could be interested in taking over this bundle if this solution is ok for you as well. Let me know.

Add support for DateTimeImmutable

I know that the current minimum required PHP version for this bundle is 5.3.3, but adding DateTimeImmutable support (only available since PHP 5.5) would be really great - I would even be glad to make the necesarry changes myself.

An exception has been thrown during the rendering of a template

An exception has been thrown during the rendering of a template ("Unable to choose a translation for "diff.ago.day" with locale "es"

to open the page I get this error, check if the translations are well written and if the format is well

en

        <trans-unit id="3">
            <source>diff.ago.day</source>
            <target>1 day ago|%count% days ago</target>
        </trans-unit>

es

<trans-unit id="3">
            <source>diff.ago.day</source>
            <target>hace 1 día|hace %count% días</target>
        </trans-unit>

Add composer instructions

I know is not difficult, but I thing that nowadays every is using or going to use composer to deal with symfony2.x

So just for having this bundle perfect ;)

change locale without effect

I use the ago function in the mailer twig template.
Before I change the local in the request to the user language. Unfortunately the translator of the ago function does not notice this and renders it in the original language.

Composer.json requirements support for Symfony 2.2

Could you please upgrade composer.json so that requirements met new Symfony 2.2?
"symfony/framework-bundle": ">=2.0,<2.3-dev"

Otherwise we cannot use this package on latest dev versions, and composer throws conflicts. Right now this package is limited to less than 2.2:
"symfony/framework-bundle": ">=2.0,<2.2-dev"

Thank you

does not display a normal time

templates
{{ time_diff('2012-10-05 16:47:13') }}

result 'diff.ago.minute'

and how to change the language? in MyProject/app/Resources/translations copy

PHP 8.0 compatibility

Are there any plans for adding compatibilty with PHP 8.0?

Would you like me to create a pull request for this?

Impossible to install via composer :

The installation just crashes....

  - Installing knplabs/knp-time-bundle (dev-master)
    Cloning ad2aecda46601eeeaa426dec49938de527e363bb



  [RuntimeException]                                                                                    
  Failed to clone http://github.com/KnpLabs/KnpTimeBundle via git, https and http protocols, aborting.  

  - git://github.com/KnpLabs/KnpTimeBundle                                                              
    fatal: reference is not a tree: ad2aecda46601eeeaa426dec49938de527e363bb                            

  - https://github.com/KnpLabs/KnpTimeBundle                                                            
    fatal: reference is not a tree: ad2aecda46601eeeaa426dec49938de527e363bb                            

  - http://github.com/KnpLabs/KnpTimeBundle                                                             
    fatal: reference is not a tree: ad2aecda46601eeeaa426dec49938de527e363bb                            

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.