function data_week() { return [[LocalDate::of(1969, 12, 29), DayOfWeek::MONDAY(), 1, 1970], [LocalDate::of(2012, 12, 23), DayOfWeek::SUNDAY(), 51, 2012], [LocalDate::of(2012, 12, 24), DayOfWeek::MONDAY(), 52, 2012], [LocalDate::of(2012, 12, 27), DayOfWeek::THURSDAY(), 52, 2012], [LocalDate::of(2012, 12, 28), DayOfWeek::FRIDAY(), 52, 2012], [LocalDate::of(2012, 12, 29), DayOfWeek::SATURDAY(), 52, 2012], [LocalDate::of(2012, 12, 30), DayOfWeek::SUNDAY(), 52, 2012], [LocalDate::of(2012, 12, 31), DayOfWeek::MONDAY(), 1, 2013], [LocalDate::of(2013, 1, 1), DayOfWeek::TUESDAY(), 1, 2013], [LocalDate::of(2013, 1, 2), DayOfWeek::WEDNESDAY(), 1, 2013], [LocalDate::of(2013, 1, 6), DayOfWeek::SUNDAY(), 1, 2013], [LocalDate::of(2013, 1, 7), DayOfWeek::MONDAY(), 2, 2013]]; }
public function test_London_getTransitionRules() { $test = $this->europeLondon(); $rules = $test->getTransitionRules(); $this->assertEquals(count($rules), 2); $in = $rules[0]; $this->assertEquals($in->getMonth(), Month::MARCH()); $this->assertEquals($in->getDayOfMonthIndicator(), 25); // optimized from -1 $this->assertEquals($in->getDayOfWeek(), DayOfWeek::SUNDAY()); $this->assertEquals($in->getLocalTime(), LocalTime::of(1, 0)); $this->assertEquals($in->getTimeDefinition(), TimeDefinition::UTC()); $this->assertEquals($in->getStandardOffset(), self::$OFFSET_ZERO); $this->assertEquals($in->getOffsetBefore(), self::$OFFSET_ZERO); $this->assertEquals($in->getOffsetAfter(), self::$OFFSET_PONE); $out = $rules[1]; $this->assertEquals($out->getMonth(), Month::OCTOBER()); $this->assertEquals($out->getDayOfMonthIndicator(), 25); // optimized from -1 $this->assertEquals($out->getDayOfWeek(), DayOfWeek::SUNDAY()); $this->assertEquals($out->getLocalTime(), LocalTime::of(1, 0)); $this->assertEquals($out->getTimeDefinition(), TimeDefinition::UTC()); $this->assertEquals($out->getStandardOffset(), self::$OFFSET_ZERO); $this->assertEquals($out->getOffsetBefore(), self::$OFFSET_PONE); $this->assertEquals($out->getOffsetAfter(), self::$OFFSET_ZERO); }
public function test_toString() { $this->assertEquals(DayOfWeek::MONDAY()->__toString(), "MONDAY"); $this->assertEquals(DayOfWeek::TUESDAY()->__toString(), "TUESDAY"); $this->assertEquals(DayOfWeek::WEDNESDAY()->__toString(), "WEDNESDAY"); $this->assertEquals(DayOfWeek::THURSDAY()->__toString(), "THURSDAY"); $this->assertEquals(DayOfWeek::FRIDAY()->__toString(), "FRIDAY"); $this->assertEquals(DayOfWeek::SATURDAY()->__toString(), "SATURDAY"); $this->assertEquals(DayOfWeek::SUNDAY()->__toString(), "SUNDAY"); }
function providerDayOfWeekData() { return [[Locale::US(), "e", "1", DayOfWeek::SUNDAY()], [Locale::US(), "ee", "01", DayOfWeek::SUNDAY()], [Locale::US(), "c", "1", DayOfWeek::SUNDAY()], [Locale::UK(), "e", "1", DayOfWeek::MONDAY()], [Locale::UK(), "ee", "01", DayOfWeek::MONDAY()], [Locale::UK(), "c", "1", DayOfWeek::MONDAY()]]; }
public function test_equals() { $weekDef_iso = WeekFields::ISO(); $weekDef_sundayStart = WeekFields::SUNDAY_START(); $this->assertTrue($weekDef_iso->equals(WeekFields::of(DayOfWeek::MONDAY(), 4))); $this->assertTrue($weekDef_sundayStart->equals(WeekFields::of(DayOfWeek::SUNDAY(), 1))); //$this->assertEquals($weekDef_iso->hashCode(), WeekFields::of(DayOfWeek::MONDAY(), 4)->hashCode()); // $this->assertEquals($weekDef_sundayStart->hashCode(), WeekFields::of(DayOfWeek::SUNDAY(), 1)->hashCode()); $this->assertFalse($weekDef_iso->equals($weekDef_sundayStart)); //$this->assertNotEquals($weekDef_iso->hashCode(), $weekDef_sundayStart->hashCode()); }
public function test_toString_floatingWeekBackwards_secondLast() { $test = ZoneOffsetTransitionRule::of(Month::MARCH(), -2, DayOfWeek::SUNDAY(), self::TIME_0100(), false, TimeDefinition::WALL(), self::OFFSET_0200(), self::OFFSET_0200(), self::OFFSET_0300()); $this->assertEquals($test->__toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day minus 1 of MARCH at 01:00 WALL, standard offset +02:00]"); }
/** * Obtains an instance of {@code WeekFields} appropriate for a locale. * <p> * This will look up appropriate values from the provider of localization data. * * @param Locale $locale the locale to use, not null * @return WeekFields the week-definition, not null */ public static function ofLocale(Locale $locale) { // TODO $locale = Locale::of($locale->getLanguage(), $locale->getCountry()); // elminate variants $cal = IntlCalendar::createInstance(null, $locale->getLocale()); $calDow = $cal->getFirstDayOfWeek(); $dow = DayOfWeek::SUNDAY()->plus($calDow - 1); $minDays = $cal->getMinimalDaysInFirstWeek(); return WeekFields::of($dow, $minDays); }