Open walik91 opened 11 years ago
return "Вчера"
if $fromTime===null
. And is correct.I wanted to make the rules for setting their records:
public $rules = array(
'm'=>array('полчаса'=> 30, 'четверть часа' => 25),
'h'=>array(),
'd'=>array('год'=> 365),
);
but Prevents me to do the following code: $this->_trimArrays($words);
private function _trimArrays(array &$arr, array &$arr2=null)
{
$i = sizeof($arr) - 1;
while ($i >= 0 && $arr[$i] == 0) {
var_dump($arr);
echo 1;
array_pop($arr);
if ($arr2)
array_pop($arr2);
--$i;
}
...
}
$arr[$i] == 0
true if "полчаса" and this delete. Problem in the line. Since it must start with a number and do not be zero....
P.S. Need to come up with some sort of a handy set of rules and check them and substitute the values.
I think, it possible even with trim. Today I will try to extend this module's functionality.
Algorithm of this function was rewritten. At now it became much better and flexible. But in which cases "полчаса" or "четверть часа" need to be returned? When a minutes strictly equals 30 or 15?
It would be great if you could set the rules for replacement:
public $rules = array(
'y' => array('1 год' => 'один год'),
'm' => array(),
'd' => array(),
'h' => array(),
'i' => array('30 минут' => 'полчаса', '15 минут' => 'четверть часа'),
);
I made a quick sketch: https://github.com/githubjeka/php_rutils/blob/50be6d6dac759f19ff3b7db4f706df789751bde2/Dt.php#L164
uses
use php_rutils\RUtils;
$accuracy = RUtils::ACCURACY_YEAR;
echo RUtils::dt()->distanceOfTimeInWords(new DateTime('now'), new DateTime('now + 1 year 3 hours 30 minute'),$accuracy);
echo RUtils::dt()->distanceOfTimeInWords(new DateTime('now - 30 minute'), new DateTime('now'),$accuracy);
echo RUtils::dt()->distanceOfTimeInWords(new DateTime('now - 15 minute'), new DateTime('now'),$accuracy);
reuslt один год назадполчаса назадчетверть часа назад
think about ..
I think about it a lot. But I think this feature is not necessary. I leave this issue open for community voting.
Why you talk on english if you russians?
Github this international place. While communicating in English, there is a chance that your code will support not only the Russian players.
I think it would be better if the phrase would be "Днем ранее" or "Вчера" (if $fromTime is today)
I think it would be better if the phrase would be "полчаса назад" or "через полчаса" (if the variables $fromTime and $toTime are interchanged)
And other similar examples