Page MenuHomePhabricator

D12723.id30570.diff
No OneTemporary

D12723.id30570.diff

diff --git a/src/view/phui/calendar/PHUICalendarDayView.php b/src/view/phui/calendar/PHUICalendarDayView.php
--- a/src/view/phui/calendar/PHUICalendarDayView.php
+++ b/src/view/phui/calendar/PHUICalendarDayView.php
@@ -277,44 +277,37 @@
}
private function getPrevDay() {
+ $user = $this->user;
+ $timezone = new DateTimeZone($user->getTimezoneIdentifier());
+
$day = $this->day;
$month = $this->month;
$year = $this->year;
- $prev_year = $year;
- $prev_month = $month;
- $prev_day = $day - 1;
- if ($prev_day == 0) {
- $prev_month--;
- if ($prev_month == 0) {
- $prev_year--;
- $prev_month = 12;
- }
- $prev_day = $this->getNumberOfDaysInMonth($prev_month, $prev_year);
- }
-
- return array($prev_year, $prev_month, $prev_day);
+ $prev = new DateTime("{$year}-{$month}-{$day}", $timezone);
+ $prev->modify('-1 day');
+ return array(
+ $prev->format('Y'),
+ $prev->format('m'),
+ $prev->format('d'),
+ );
}
private function getNextDay() {
+ $user = $this->user;
+ $timezone = new DateTimeZone($user->getTimezoneIdentifier());
+
$day = $this->day;
$month = $this->month;
$year = $this->year;
- $next_year = $year;
- $next_month = $month;
- $next_day = $day + 1;
- $days_in_month = $this->getNumberOfDaysInMonth($month, $year);
- if ($next_day > $days_in_month) {
- $next_day = 1;
- $next_month++;
- }
- if ($next_month == 13) {
- $next_year++;
- $next_month = 1;
- }
-
- return array($next_year, $next_month, $next_day);
+ $prev = new DateTime("{$year}-{$month}-{$day}", $timezone);
+ $prev->modify('+1 day');
+ return array(
+ $prev->format('Y'),
+ $prev->format('m'),
+ $prev->format('d'),
+ );
}
private function getNextYearAndMonth($month, $year) {
@@ -341,7 +334,6 @@
private function getDateTime() {
$user = $this->user;
-
$timezone = new DateTimeZone($user->getTimezoneIdentifier());
$day = $this->day;
diff --git a/src/view/phui/calendar/PHUICalendarMonthView.php b/src/view/phui/calendar/PHUICalendarMonthView.php
--- a/src/view/phui/calendar/PHUICalendarMonthView.php
+++ b/src/view/phui/calendar/PHUICalendarMonthView.php
@@ -251,31 +251,33 @@
}
private function getNextYearAndMonth() {
+ $user = $this->user;
+ $timezone = new DateTimeZone($user->getTimezoneIdentifier());
+
$month = $this->month;
$year = $this->year;
- $next_year = $year;
- $next_month = $month + 1;
- if ($next_month == 13) {
- $next_year = $year + 1;
- $next_month = 1;
- }
-
- return array($next_year, $next_month);
+ $prev = new DateTime("{$year}-{$month}", $timezone);
+ $prev->modify('+1 month');
+ return array(
+ $prev->format('Y'),
+ $prev->format('m'),
+ );
}
private function getPrevYearAndMonth() {
+ $user = $this->user;
+ $timezone = new DateTimeZone($user->getTimezoneIdentifier());
+
$month = $this->month;
$year = $this->year;
- $prev_year = $year;
- $prev_month = $month - 1;
- if ($prev_month == 0) {
- $prev_year = $year - 1;
- $prev_month = 12;
- }
-
- return array($prev_year, $prev_month);
+ $prev = new DateTime("{$year}-{$month}", $timezone);
+ $prev->modify('-1 month');
+ return array(
+ $prev->format('Y'),
+ $prev->format('m'),
+ );
}
/**

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 10, 9:03 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7739205
Default Alt Text
D12723.id30570.diff (3 KB)

Event Timeline