public function testGetCalendarSpecificLocale() { $locale = 'ru_RU'; $language = 'fr_CA'; $this->configManager->expects($this->never())->method($this->anything()); $calendar = $this->getMock('Oro\\Bundle\\LocaleBundle\\Model\\Calendar'); $this->calendarFactory->expects($this->once())->method('getCalendar')->with($locale, $language)->will($this->returnValue($calendar)); $this->assertSame($calendar, $this->localeSettings->getCalendar($locale, $language)); }
/** * @param \DateTime|null $date * @return array */ public function getDateRange(\DateTime $date = null) { $timezone = $this->localeSettings->getTimeZone(); $timezoneObj = new \DateTimeZone($timezone); if (null === $date) { $date = new \DateTime('now', $timezoneObj); } else { $date->setTimezone($timezoneObj); } $firstDay = $this->localeSettings->getCalendar()->getFirstDayOfWeek() - 1; $startDate = clone $date; $startDate->setDate($date->format('Y'), $date->format('n'), 1); $startDate->setTime(0, 0, 0); $startDate->sub(new \DateInterval('P' . ((int) $startDate->format('w') - $firstDay + 7) % 7 . 'D')); $endDate = clone $startDate; $endDate->add(new \DateInterval('P6W')); return array('startDate' => $startDate, 'endDate' => $endDate); }
/** * Gets first day of week according to constants of Calendar. * * @param string|null $locale * @return string */ public function getFirstDayOfWeek($locale = null) { return $this->localeSettings->getCalendar($locale)->getFirstDayOfWeek(); }