Skip to content

Commit

Permalink
Added: before and yesterday diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
JanGalek committed Apr 6, 2018
1 parent 964d2f5 commit 0431db6
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 83 deletions.
32 changes: 22 additions & 10 deletions src/Galek/Utils/Calendar/Calendar.php
Expand Up @@ -402,19 +402,31 @@ public function getDateTimeFormat(): string
public function werbDif(): string
{
$curDate = new Calendar();
$diff = $this->diff($curDate)->days;
$date = clone $this;
$date->setTime(0,0,0,0);
$curDate->setTime(0,0,0,0);
$diff = $date->diff($curDate)->days;


$local = $this->configuration->getLocalization()->getDifference();

if ($diff === 0) {
return $local['today'];
} elseif ($diff === 1) {
return $local['tomorrow'];
} elseif ($diff === 2) {
return $local['afterTomorrow'];
} elseif ($diff < 5) {
return $local['after'] . ' ' . $diff . ' ' . $local['twoDays'];
}
if ($date >= $curDate) {
if ($diff === 0) {
return $local['today'];
} elseif ($diff === 1) {
return $local['tomorrow'];
} elseif ($diff === 2) {
return $local['afterTomorrow'];
} elseif ($diff < 5) {
return $local['after'] . ' ' . $diff . ' ' . $local['twoDays'];
}
} else {
if ($diff === 1) {
return $local['yesterday'];
} else {
return $local[ 'before' ] . ' ' . $diff . ' ' . $local[ 'twoDays' ];
}
}

return $local['after'] . ' ' . $diff . ' ' . $local['fiveDays'];
}
Expand Down
2 changes: 2 additions & 0 deletions src/Galek/Utils/Calendar/Localization/cs.neon
Expand Up @@ -58,6 +58,8 @@ inflexion:
7: 'sobotou'

difference:
before: 'před'
yesterday: 'včera'
today: 'dnes'
tomorrow: 'zítra'
afterTomorrow: 'pozítří'
Expand Down
2 changes: 2 additions & 0 deletions src/Galek/Utils/Calendar/Localization/en.neon
Expand Up @@ -58,6 +58,8 @@ inflexion:
7: 'saturday'

difference:
before: 'before'
yesterday: 'yesterday'
today: 'today'
tomorrow: 'tomorrow'
afterTomorrow: 'after tomorrow'
Expand Down
2 changes: 2 additions & 0 deletions src/Galek/Utils/Calendar/Localization/sk.neon
Expand Up @@ -58,6 +58,8 @@ inflexion:
7: 'sobotou'

difference:
before: 'pred'
yesterday: 'včera'
today: 'dnes'
tomorrow: 'zajtra'
afterTomorrow: 'pozajtra'
Expand Down
2 changes: 1 addition & 1 deletion tests/CalendarTests/Shippers.phpt
Expand Up @@ -77,7 +77,7 @@ public const CONFIG = [

public function testCustom1()
{
$configurator = new \GalekTests\Calendar\Models\Configurator(self::CONFIG);
$configurator = new \Galek\Utils\Calendar\Configuration\Configurator(self::CONFIG);

$date = new Calendar('2018-03-29 12:00');

Expand Down
22 changes: 0 additions & 22 deletions tests/CalendarTests/models/Configurator.php

This file was deleted.

27 changes: 0 additions & 27 deletions tests/CalendarTests/models/Shipper.php

This file was deleted.

23 changes: 0 additions & 23 deletions tests/CalendarTests/models/Shippers.php

This file was deleted.

0 comments on commit 0431db6

Please sign in to comment.