|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the core-library package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2018 NdC/WBW |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace WBW\Library\Core\Utility; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Date utility. |
|
16
|
|
|
* |
|
17
|
|
|
* @author webeweb <https://github.com/webeweb/> |
|
18
|
|
|
* @package WBW\Library\Core\Utility |
|
19
|
|
|
* @final |
|
20
|
|
|
*/ |
|
21
|
|
|
final class DateUtility implements DateUtilityInterface { |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Get the weekday into FR. |
|
25
|
|
|
* |
|
26
|
|
|
* @return array Returns the weekday into FR. |
|
27
|
|
|
*/ |
|
28
|
|
|
public static function getWeekdayFR() { |
|
29
|
|
|
return [ |
|
30
|
|
|
self::EN_WEEKDAY_SUNDAY => self::FR_WEEKDAY_SUNDAY, |
|
31
|
|
|
self::EN_WEEKDAY_MONDAY => self::FR_WEEKDAY_MONDAY, |
|
32
|
|
|
self::EN_WEEKDAY_TUESDAY => self::FR_WEEKDAY_TUESDAY, |
|
33
|
|
|
self::EN_WEEKDAY_WEDNESDAY => self::FR_WEEKDAY_WEDNESDAY, |
|
34
|
|
|
self::EN_WEEKDAY_THURSDAY => self::FR_WEEKDAY_THURSDAY, |
|
35
|
|
|
self::EN_WEEKDAY_FRIDAY => self::FR_WEEKDAY_FRIDAY, |
|
36
|
|
|
self::EN_WEEKDAY_SATURDAY => self::FR_WEEKDAY_SATURDAY, |
|
37
|
|
|
]; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Translate the weekday part. |
|
42
|
|
|
* |
|
43
|
|
|
* @param string $date The date. |
|
44
|
|
|
* @param array $translations The translations: day => translation. |
|
45
|
|
|
* @return string Returns the weekday part translated. |
|
46
|
|
|
*/ |
|
47
|
|
|
public static function translateWeekday($date, array $translations = []) { |
|
48
|
|
|
return StringUtility::replace($date, array_keys($translations), array_values($translations)); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|