1 | <?php |
||
24 | final class DateUtility implements DateUtilityInterface { |
||
25 | |||
26 | /** |
||
27 | * Get a day number. |
||
28 | * |
||
29 | * @param DateTime $date The date. |
||
30 | * @return integer Returns the day number between 1 and 7 with monday equals to 1. |
||
31 | */ |
||
32 | public static function getDayNumber(DateTime $date) { |
||
35 | |||
36 | /** |
||
37 | * Get a month number. |
||
38 | * |
||
39 | * @param DateTime $date The date. |
||
40 | * @return integer Returns the month number. |
||
41 | */ |
||
42 | public static function getMonthNumber(DateTime $date) { |
||
43 | return intval($date->format("m")); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Get a week number. |
||
48 | * |
||
49 | * @param DateTime $date The date. |
||
50 | * @return integer Returns the week number. |
||
51 | */ |
||
52 | public static function getWeekNumber(DateTime $date) { |
||
55 | |||
56 | /** |
||
57 | * Get a week number to apply with a schedule. |
||
58 | * |
||
59 | * <p> |
||
60 | * For example: |
||
61 | * We have a schedule etablished over 5 weeks. |
||
62 | * |
||
63 | * We start the schedule with the week number 1. |
||
64 | * If the current date is 2018-01-01 and the start date is 2018-01-01, the week number is 1 |
||
65 | * If the current date is 2018-01-08 and the start date is 2018-01-01, the week number is 2 |
||
66 | * etc. |
||
67 | * |
||
68 | * We start the schedule with the week number 3. |
||
69 | * If the current date is 2018-01-01 and the start date is 2018-01-01, the week number is 3 |
||
70 | * If the current date is 2018-01-08 and the start date is 2018-01-01, the week number is 4 |
||
71 | * etc. |
||
72 | * </p> |
||
73 | * |
||
74 | * @param DateTime $date The date. |
||
75 | * @param DateTime $startDate The start date. |
||
76 | * @param integer $weekCount The week count. |
||
77 | * @param integer $weekNumber The week number. |
||
78 | * @return integer Returns the week number to apply between 1 and $weekCount. |
||
79 | */ |
||
80 | public static function getWeekNumberToApply(DateTime $date, DateTime $startDate, $weekCount, $weekNumber) { |
||
101 | |||
102 | /** |
||
103 | * Get the weekday into FR. |
||
104 | * |
||
105 | * @return array Returns the weekday into FR. |
||
106 | */ |
||
107 | public static function getWeekdayFR() { |
||
118 | |||
119 | /** |
||
120 | * Get a year number. |
||
121 | * |
||
122 | * @param DateTime $date The date. |
||
123 | * @return integer Returns the year number. |
||
124 | */ |
||
125 | public static function getYearNumber(DateTime $date) { |
||
128 | |||
129 | /** |
||
130 | * Translate the weekday part. |
||
131 | * |
||
132 | * @param string $date The date. |
||
133 | * @param array $translations The translations: day => translation. |
||
134 | * @return string Returns the weekday part translated. |
||
135 | */ |
||
136 | public static function translateWeekday($date, array $translations = []) { |
||
139 | |||
140 | } |
||
141 |