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());
 }
Example #2
0
 /**
  * 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);
 }