1 | <?php |
||
8 | abstract class DateTimeUtil |
||
9 | { |
||
10 | /** |
||
11 | * Returns true if the given date time is a Saturday or Sunday. |
||
12 | * |
||
13 | * @param \DateTime $dateTime The date/time object. |
||
14 | * |
||
15 | * @return boolean |
||
16 | */ |
||
17 | final public static function isWeekendDay(\DateTime $dateTime) |
||
22 | |||
23 | /** |
||
24 | * Returns true if the given date time is not a Saturday or Sunday. |
||
25 | * |
||
26 | * @param \DateTime $dateTime The date/time object. |
||
27 | * |
||
28 | * @return boolean |
||
29 | */ |
||
30 | final public static function isWeekDay(\DateTime $dateTime) |
||
35 | |||
36 | /** |
||
37 | * Returns true if the given dates occur on the same year, month and day. |
||
38 | * |
||
39 | * @param \DateTime $thisDate A date to compare. |
||
40 | * @param \DateTime $thatDate A date to compare. |
||
41 | * |
||
42 | * @return boolean |
||
43 | */ |
||
44 | final public static function isSameDay(\DateTime $thisDate, \DateTime $thatDate) |
||
49 | |||
50 | /** |
||
51 | * Indicates whether the given instance of DateTime is within the daylight saving time range for the current time |
||
52 | * zone. |
||
53 | * |
||
54 | * @param \DateTime $dateTime The date/time object. |
||
55 | * |
||
56 | * @return boolean |
||
57 | */ |
||
58 | final public static function isDaylightSavings(\DateTime $dateTime) |
||
62 | |||
63 | /** |
||
64 | * Returns true if the given date is between the provided date range. |
||
65 | * |
||
66 | * @param \DateTime $subjectDate The date/time object being checked. |
||
67 | * @param \DateTime $startDate The start date/time object. |
||
68 | * @param \DateTime $endDate The end date/time object. |
||
69 | * |
||
70 | * @return boolean |
||
71 | * @throws \DomainException Thrown when an invalid date range is provided. |
||
72 | */ |
||
73 | final public static function isInRange(\DateTime $subjectDate, \DateTime $startDate, \DateTime $endDate) |
||
83 | |||
84 | /** |
||
85 | * Returns the given DateTime instance as a "time ago" string. |
||
86 | * |
||
87 | * @param \DateTime $dateTime The DateTime object to present as an ago string. |
||
88 | * |
||
89 | * @return string |
||
90 | * |
||
91 | * @throws \DomainException Thrown if the given $dateTime is in the future. |
||
92 | */ |
||
93 | final public static function asAgoString(\DateTime $dateTime) |
||
122 | } |
||
123 |