Giter VIP home page Giter VIP logo

php-time-ago's People

Contributors

ajenbo avatar akavolkol avatar andersahn avatar arthurhoaro avatar baivong avatar barohatoum avatar cmfcmf avatar derekmd avatar dhutapratama avatar emadzz avatar esrefesen avatar fvodslon avatar geerteltink avatar gugoan avatar intarstudents avatar ironsmile avatar jimmiw avatar jlratwil avatar jmontoyaa avatar k1sul1 avatar khrizt avatar killmenot avatar lamberttraccard avatar mopamo avatar nikopeikrishvili avatar piamancini avatar ruben-haegeman avatar twisty avatar vegagame avatar zreedeecom 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

php-time-ago's Issues

1 months ago

Hi,

It seems there is an error between 1 and 2 months.

month-ago

Could you check it?

Thanks!

Translations\Zh_Tw does not comply with psr-4 autoloading standard

FYI, for more recent version 3.1.0, I get this deprecation notice when adding "jimmiw/php-time-ago": "^3.1.0":
tocomposer.json`:

Deprecation Notice: Class Westsworld\TimeAgo\Translations\Zh_Tw located in ./wp-content/plugins/composer-libs/jimmiw/php-time-ago/src/Westsworld/TimeAgo/Translations/Zh_TW.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///home/yuvilio/apps/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
$ composer --version
Composer version 1.10.5 2020-04-10 11:44:22
$ php --version
PHP 7.4.4 (cli) (built: Apr 27 2020 00:25:38) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
$ 

Catalan translation

Hi Jimmi great class, good job! I've created the catalan translation. I attach the file in case you want to add it. Thanks.
ca.txt

Change language

How would i set Swedish language?

Danish translation seems to work:

  $filter = new Twig_SimpleFilter('timeago', function ($datetime) {
    $timeago = new Westsworld\TimeAgo( new \Westsworld\TimeAgo\Translations\Da() );

    return $timeago->inWords( new DateTime( $datetime ) );
  });

But not Swedish (or any other translation class with underscore in its class name):

  $filter = new Twig_SimpleFilter('timeago', function ($datetime) {
    $timeago = new Westsworld\TimeAgo( new \Westsworld\TimeAgo\Translations\Sv_SE() );

    return $timeago->inWords( new DateTime( $datetime ) );
  });

What am i doing wrong? @jimmiw

Plural occurs for 1 minute

Looks the same as the issue fixed in 0.4.3 "Added a fix for “about 1 hour ago”, which would yield “1 hours ago” if the time was 1hour 30minutes. Giving a pluralization error."

The same occurs for minutes, where it renders the text '1 minutes ago'.

Add "short" english language-class

I've just discovered php-time-ago and think its just great! There's just one thing:
In my opinion, 'about 1 hour ago' is a bit to long in some cases, so it would be great if you could add something like a shorter English language-class like this:

` 0 <-> 29 secs # => <1m

30 secs <-> 1 min, 29 secs # => 1m

1 min, 30 secs <-> 44 mins, 29 secs # => [2..44] m

44 mins, 30 secs <-> 89 mins, 29 secs # => ~1h

89 mins, 29 secs <-> 23 hrs, 59 mins, 29 secs # => ~ [2..24] h

23 hrs, 59 mins, 29 secs <-> 47 hrs, 59 mins, 29 secs # => 1d

47 hrs, 59 mins, 29 secs <-> 29 days, 23 hrs, 59 mins, 29 secs # => [2..29] d

29 days, 23 hrs, 59 mins, 30 secs <-> 59 days, 23 hrs, 59 mins, 29 secs # => ~1M

59 days, 23 hrs, 59 mins, 30 secs <-> 1 yr minus 1 sec # => [2..12] M

1 yr <-> 2 yrs minus 1 secs # => 1y

2 yrs <-> max time or date # => >[2..X] y`

"46 years ago"?

Hi there,

There seems to be a problem with the output of this code when the time of the date object is between 23:00 (11PM) and 00:00 (12 PM).

When this happens, it says that it is "46 years ago".

How can I add my own translation files?

I want to add it.php translation file, I know I can do this by simply adding the file in the translations directory, but that does not seem like an ideal solution to me.

Is it possible to have a function that loads language from an array? (This way I can store translations in my production code and not the vendor directory)

About 1 hours

DateInterval dump:

y => 0
m => 0
d => 0
h => 1
i => 50
s => 25
f => 0.90637199999999996

but rule 5 is used => about 1 hours

SK translation

Hi Jimmi,

could you please make me a contributor? I have a pull request with sk language translation.

Thanks,
Franta

Add short versions?

Hi,

I was wondering if it would be easy to add short versions of the times like instead of "2 days ago" something like "2d".

Thanks

Unix timestamp

sorry i did not see the other only one issue :D somehow you can close this

Translations are problematic

It would be better to include ago in all the translation messages (i.e. about 1 hour ago), because:

  • is there any use case where it isn't followed by ago?
  • the German translation doesn't really work. about 1 hour would be translated by etwa eine Stunde, whereas about 1 hour ago would be translated by vor etwa eineR Stunde (please notice the r). So I can't just prepend vor (ago) to the translations of this library.

Do you see what I mean?

Where lost $timezone in constructor ?

/**
* TimeAgo constructor.
* @param null|DateTimeZone $timezone the timezone to use (uses system if none is given)
* @param string $language the language to use (defaults to 'en' for english)
*/
public function __construct(Language $language = null)
{
$this->language = $language;
}

@param null|DateTimeZone $timezone the timezone to use (uses system if none is given)

Where ??

Why is all the logic/calculation in the Language class?

The logic for the time ago calculations is currently entirely in the Language class, which, given its name, seems odd; shouldn't it only do the translations? Wouldn't the processing have a better place in either the TimeAgo class or another one dedicated to that task?

PHP Parse error?

I get:
PHP Parse error: syntax error, unexpected ':', expecting ';' or '{'
in vendor/jimmiw/php-time-ago/src/Westsworld/TimeAgo.php on line 56?

Bug within isLessThan44Min29Secs

Please fix this inside isLessThan44Min29Secs:

return $timeDifference->i < 45 &&
$timeDifference->s < 30 &&
...

as soon the $timeDifference->s >= 30 it gives a wrong result back.

["years"]=> int(0) ["months"]=> int(0) ["days"]=> int(0) ["hours"]=> int(0) ["minutes"]=> int(36) ["seconds"]=> int(58)
about 1 hour ago -> wrong

3 seconds later:

["years"]=> int(0) ["months"]=> int(0) ["days"]=> int(0) ["hours"]=> int(0) ["minutes"]=> int(37) ["seconds"]=> int(1)
37 minutes ago -> correct

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.