jizuscreed / time-approximator
A small library to generate short approximate human friendly time description. Inspired by https://github.com/martinandert/damals
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/jizuscreed/time-approximator
Requires
- php: ^7.1.3
Requires (Dev)
This package is auto-updated.
Last update: 2025-10-20 10:39:22 UTC
README
A small library to generate short approximate human friendly time description. Inspired by https://github.com/martinandert/damals
Installation
composer require jizuscreed/time-approximator
Instantiation
$timeApproximator = new jizuscreed\TimeApproximator\TimeApproximator(new \jizuscreed\TimeApproximator\Languages\Russian());
It can
$this->timeApproximator->getDescriptionFor(20); // полминуты $this->timeApproximator->getDescriptionFor(40); // меньше чем 1 минута $this->timeApproximator->getDescriptionFor(16*60); // 16 минут $this->timeApproximator->getDescriptionFor(11*60); // 11 минут $this->timeApproximator->getDescriptionFor(46*60); // примерно 1 час $this->timeApproximator->getDescriptionFor(43*60); // 43 минуты $this->timeApproximator->getDescriptionFor(68*60); // примерно 1 час $this->timeApproximator->getDescriptionFor(24*60*60*15+23*60*60+15*600; // 16 дней)
Create language pack
Just create class in jizuscreed\TimeApproximator\Languages inheriting jizuscreed\TimeApproximator\Languages\AbstractLanguagePack and implement abstract methods
Contributing
Please, send your pull requests, especially with language packs