コード例 #1
0
ファイル: TZRule.php プロジェクト: celest-time/prototype
 /**
  * Converts this to a transition rule.
  *
  * @param ZoneOffset $standardOffset the active standard offset, not null
  * @param int $savingsBeforeSecs the active savings before the transition in seconds
  * @return ZoneOffsetTransitionRule the transition, not null
  */
 function toTransitionRule(ZoneOffset $standardOffset, $savingsBeforeSecs)
 {
     // optimize stored format
     if ($this->dayOfMonthIndicator < 0) {
         if ($this->month != Month::FEBRUARY()) {
             $this->dayOfMonthIndicator = $this->month->maxLength() - 6;
         }
     }
     if ($this->timeEndOfDay && $this->dayOfMonthIndicator > 0 && ($this->dayOfMonthIndicator === 28 && $this->month == Month::FEBRUARY()) == false) {
         $date = LocalDate::ofMonth(2004, $this->month, $this->dayOfMonthIndicator)->plusDays(1);
         // leap-year
         $this->month = $date->getMonth();
         $this->dayOfMonthIndicator = $date->getDayOfMonth();
         if ($this->dayOfWeek !== null) {
             $this->dayOfWeek = $this->dayOfWeek->plus(1);
         }
         $this->timeEndOfDay = false;
     }
     // build rule
     $trans = $this->toTransition($standardOffset, $savingsBeforeSecs);
     return ZoneOffsetTransitionRule::of($this->month, $this->dayOfMonthIndicator, $this->dayOfWeek, $this->time, $this->timeEndOfDay, $this->timeDefinition, $standardOffset, $trans->getOffsetBefore(), $trans->getOffsetAfter());
 }
コード例 #2
0
 public function test_getDayOfWeek()
 {
     $dow = DayOfWeek::MONDAY();
     foreach (Month::values() as $month) {
         $length = $month->length(false);
         for ($i = 1; $i <= $length; $i++) {
             $d = LocalDate::ofMonth(2007, $month, $i);
             $this->assertSame($d->getDayOfWeek(), $dow);
             $dow = $dow->plus(1);
         }
     }
 }
コード例 #3
0
ファイル: IsoFields.php プロジェクト: celest-time/prototype
 /**
  * @internal
  * @param int
  * @return int
  */
 public static function getWeekRangeInt($wby)
 {
     $date = LocalDate::of($wby, 1, 1);
     // 53 weeks if standard year starts on Thursday, or Wed in a leap year
     if ($date->getDayOfWeek() == DayOfWeek::THURSDAY() || $date->getDayOfWeek() == DayOfWeek::WEDNESDAY() && $date->isLeapYear()) {
         return 53;
     }
     return 52;
 }
コード例 #4
0
 protected function resolveAligned(ChronoLocalDate $base, $months, $weeks, $dow)
 {
     $date = $base->plus($months, ChronoUnit::MONTHS())->plus($weeks, ChronoUnit::WEEKS());
     if ($dow > 7) {
         $date = $date->plus(($dow - 1) / 7, ChronoUnit::WEEKS());
         $dow = ($dow - 1) % 7 + 1;
     } else {
         if ($dow < 1) {
             $date = $date->plus(Math::subtractExact($dow, 7) / 7, ChronoUnit::WEEKS());
             $dow = ($dow + 6) % 7 + 1;
         }
     }
     return $date->adjust(TemporalAdjusters::nextOrSame(DayOfWeek::of((int) $dow)));
 }
コード例 #5
0
 /**
  * @group long
  */
 public function test_loop()
 {
     // loop round at least one 400 $year cycle, including before 1970
     $date = LocalDate::of(1960, 1, 5);
     // Tuseday of $week 1 1960
     $year = 1960;
     $wby = 1960;
     $weekLen = 52;
     $week = 1;
     while ($date->getYear() < 2400) {
         $loopDow = $date->getDayOfWeek();
         if ($date->getYear() != $year) {
             $year = $date->getYear();
         }
         if ($loopDow == DayOfWeek::MONDAY()) {
             $week++;
             if ($week == 53 && $weekLen == 52 || $week == 54) {
                 $week = 1;
                 $firstDayOfWeekBasedYear = $date->plusDays(14)->withDayOfYear(1);
                 $firstDay = $firstDayOfWeekBasedYear->getDayOfWeek();
                 $weekLen = $firstDay == DayOfWeek::THURSDAY() || $firstDay == DayOfWeek::WEDNESDAY() && $firstDayOfWeekBasedYear->isLeapYear() ? 53 : 52;
                 $wby++;
             }
         }
         $this->assertEquals(IsoFields::WEEK_OF_WEEK_BASED_YEAR()->rangeRefinedBy($date), ValueRange::of(1, $weekLen), "Failed on " . $date . " " . $date->getDayOfWeek());
         $this->assertEquals(IsoFields::WEEK_OF_WEEK_BASED_YEAR()->getFrom($date), $week, "Failed on " . $date . " " . $date->getDayOfWeek());
         $this->assertEquals($date->get(IsoFields::WEEK_OF_WEEK_BASED_YEAR()), $week, "Failed on " . $date . " " . $date->getDayOfWeek());
         $this->assertEquals(IsoFields::WEEK_BASED_YEAR()->getFrom($date), $wby, "Failed on " . $date . " " . $date->getDayOfWeek());
         $this->assertEquals($date->get(IsoFields::WEEK_BASED_YEAR()), $wby, "Failed on " . $date . " " . $date->getDayOfWeek());
         $date = $date->plusDays(1);
     }
 }
コード例 #6
0
 public function test_enum()
 {
     $this->assertEquals(DayOfWeek::valueOf("MONDAY"), DayOfWeek::MONDAY());
     $this->assertEquals(DayOfWeek::values()[0], DayOfWeek::MONDAY());
 }
コード例 #7
0
 public function test_previousOrCurrent()
 {
     foreach (Month::values() as $month) {
         for ($i = 1; $i <= $month->length(false); $i++) {
             $date = self::date(2007, $month, $i);
             foreach (DayOfWeek::values() as $dow) {
                 $test = TemporalAdjusters::previousOrSame($dow)->adjustInto($date);
                 $this->assertSame($test->getDayOfWeek(), $dow);
                 if ($test->getYear() == 2007) {
                     $dayDiff = $test->getDayOfYear() - $date->getDayOfYear();
                     $this->assertTrue($dayDiff <= 0 && $dayDiff > -7);
                     $this->assertEquals($date->equals($test), $date->getDayOfWeek() == $dow);
                 } else {
                     $this->assertFalse($date->getDayOfWeek() == $dow);
                     $this->assertSame($month, Month::JANUARY());
                     $this->assertTrue($date->getDayOfMonth() < 7);
                     $this->assertEquals($test->getYear(), 2006);
                     $this->assertSame($test->getMonth(), Month::DECEMBER());
                     $this->assertTrue($test->getDayOfMonth() > 25);
                 }
             }
         }
     }
 }
コード例 #8
0
 function data_format_withZone_withChronology()
 {
     $ym = YearMonth::of(2008, 6);
     $ld = LocalDate::of(2008, 6, 30);
     $lt = LocalTime::of(11, 30);
     $ldt = LocalDateTime::of(2008, 6, 30, 11, 30);
     $ot = OffsetTime::ofLocalTime(LocalTime::of(11, 30), self::OFFSET_PONE());
     $odt = OffsetDateTime::ofDateTime(LocalDateTime::of(2008, 6, 30, 11, 30), self::OFFSET_PONE());
     $zdt = ZonedDateTime::ofDateTime(LocalDateTime::of(2008, 6, 30, 11, 30), self::ZONE_PARIS());
     $thaiZdt = ThaiBuddhistChronology::INSTANCE()->zonedDateTimeFrom($zdt);
     $instant = Instant::ofEpochSecond(3600);
     return [[null, null, DayOfWeek::MONDAY(), "::::"], [null, null, $ym, "2008::::ISO"], [null, null, $ld, "2008::::ISO"], [null, null, $lt, ":11:::"], [null, null, $ldt, "2008:11:::ISO"], [null, null, $ot, ":11:+01:00::"], [null, null, $odt, "2008:11:+01:00::ISO"], [null, null, $zdt, "2008:11:+02:00:Europe/Paris:ISO"], [null, null, $instant, "::::"], [IsoChronology::INSTANCE(), null, DayOfWeek::MONDAY(), "::::ISO"], [IsoChronology::INSTANCE(), null, $ym, "2008::::ISO"], [IsoChronology::INSTANCE(), null, $ld, "2008::::ISO"], [IsoChronology::INSTANCE(), null, $lt, ":11:::ISO"], [IsoChronology::INSTANCE(), null, $ldt, "2008:11:::ISO"], [IsoChronology::INSTANCE(), null, $ot, ":11:+01:00::ISO"], [IsoChronology::INSTANCE(), null, $odt, "2008:11:+01:00::ISO"], [IsoChronology::INSTANCE(), null, $zdt, "2008:11:+02:00:Europe/Paris:ISO"], [IsoChronology::INSTANCE(), null, $instant, "::::ISO"], [null, self::ZONE_PARIS(), DayOfWeek::MONDAY(), ":::Europe/Paris:"], [null, self::ZONE_PARIS(), $ym, "2008:::Europe/Paris:ISO"], [null, self::ZONE_PARIS(), $ld, "2008:::Europe/Paris:ISO"], [null, self::ZONE_PARIS(), $lt, ":11::Europe/Paris:"], [null, self::ZONE_PARIS(), $ldt, "2008:11::Europe/Paris:ISO"], [null, self::ZONE_PARIS(), $ot, ":11:+01:00:Europe/Paris:"], [null, self::ZONE_PARIS(), $odt, "2008:12:+02:00:Europe/Paris:ISO"], [null, self::ZONE_PARIS(), $zdt, "2008:11:+02:00:Europe/Paris:ISO"], [null, self::ZONE_PARIS(), $instant, "1970:02:+01:00:Europe/Paris:ISO"], [null, self::OFFSET_PTHREE(), DayOfWeek::MONDAY(), ":::+03:00:"], [null, self::OFFSET_PTHREE(), $ym, "2008:::+03:00:ISO"], [null, self::OFFSET_PTHREE(), $ld, "2008:::+03:00:ISO"], [null, self::OFFSET_PTHREE(), $lt, ":11::+03:00:"], [null, self::OFFSET_PTHREE(), $ldt, "2008:11::+03:00:ISO"], [null, self::OFFSET_PTHREE(), $ot, null], [null, self::OFFSET_PTHREE(), $odt, "2008:13:+03:00:+03:00:ISO"], [null, self::OFFSET_PTHREE(), $zdt, "2008:12:+03:00:+03:00:ISO"], [null, self::OFFSET_PTHREE(), $instant, "1970:04:+03:00:+03:00:ISO"], [ThaiBuddhistChronology::INSTANCE(), null, DayOfWeek::MONDAY(), null], [ThaiBuddhistChronology::INSTANCE(), null, $ym, null], [ThaiBuddhistChronology::INSTANCE(), null, $ld, "2551::::ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), null, $lt, ":11:::ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), null, $ldt, "2551:11:::ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), null, $ot, ":11:+01:00::ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), null, $odt, "2551:11:+01:00::ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), null, $zdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), null, $instant, "::::ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), null, DayOfWeek::MONDAY(), null], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $ym, null], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $ld, "2551:::Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $lt, ":11::Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $ldt, "2551:11::Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $ot, ":11:+01:00:Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $odt, "2551:12:+02:00:Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $zdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $instant, "2513:02:+01:00:Europe/Paris:ThaiBuddhist"], [null, self::ZONE_PARIS(), $thaiZdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"], [ThaiBuddhistChronology::INSTANCE(), self::ZONE_PARIS(), $thaiZdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"], [IsoChronology::INSTANCE(), self::ZONE_PARIS(), $thaiZdt, "2008:11:+02:00:Europe/Paris:ISO"]];
 }
コード例 #9
0
 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());
 }
コード例 #10
0
 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]");
 }
コード例 #11
0
 /**
  * @param string $str
  * @return DayOfWeek
  * @throws IllegalArgumentException
  */
 private function parseDayOfWeek($str)
 {
     if (preg_match(self::$DOW, $str, $mr)) {
         for ($dow = 1; $dow < 8 && $dow < count($mr); $dow++) {
             if ($mr[$dow] !== '') {
                 return DayOfWeek::of($dow);
             }
         }
     }
     throw new IllegalArgumentException("Unknown day-of-week: " . $str);
 }
コード例 #12
0
ファイル: DayOfWeek.php プロジェクト: celest-time/prototype
     * </pre>
     * <p>
     * For example, given a date that is a Wednesday, the following are output:
     * <pre>
     *   dateOnWed.with(MONDAY);     // two days earlier
     *   dateOnWed.with(TUESDAY);    // one day earlier
     *   dateOnWed.with(WEDNESDAY);  // same date
     *   dateOnWed.with(THURSDAY);   // one day later
     *   dateOnWed.with(FRIDAY);     // two days later
     *   dateOnWed.with(SATURDAY);   // three days later
     *   dateOnWed.with(SUNDAY);     // four days later
     * </pre>
     * <p>
     * This instance is immutable and unaffected by this method call.
     *
     * @param Temporal $temporal the target object to be adjusted, not null
     * @return Temporal the adjusted object, not null
     * @throws DateTimeException if unable to make the adjustment
     * @throws ArithmeticException if numeric overflow occurs
     */
    public function adjustInto(Temporal $temporal)
    {
        return $temporal->with(ChronoField::DAY_OF_WEEK(), $this->getValue());
    }
    public function __toString()
    {
        return $this->name;
    }
}
DayOfWeek::init();
コード例 #13
0
ファイル: WeekFields.php プロジェクト: celest-time/prototype
 /**
  * Obtains an instance of {@code WeekFields} from the first day-of-week and minimal days.
  * <p>
  * The first day-of-week defines the ISO {@code DayOfWeek} that is day 1 of the week.
  * The minimal number of days in the first week defines how many days must be present
  * in a month or year, starting from the first day-of-week, before the week is counted
  * as the first week. A value of 1 will count the first day of the month or year as part
  * of the first week, whereas a value of 7 will require the whole seven days to be in
  * the new month or year.
  * <p>
  * WeekFields instances are singletons; for each unique combination
  * of {@code firstDayOfWeek} and {@code minimalDaysInFirstWeek} the
  * the same instance will be returned.
  *
  * @param DayOfWeek $firstDayOfWeek the first day of the week, not null
  * @param int $minimalDaysInFirstWeek the minimal number of days in the first week, from 1 to 7
  * @return WeekFields the week-definition, not null
  * @throws IllegalArgumentException if the minimal days value is less than one
  *      or greater than 7
  */
 public static function of(DayOfWeek $firstDayOfWeek, $minimalDaysInFirstWeek)
 {
     $key = $firstDayOfWeek->__toString() . $minimalDaysInFirstWeek;
     $rules = @self::$CACHE[$key];
     if ($rules === null) {
         $rules = new WeekFields($firstDayOfWeek, $minimalDaysInFirstWeek);
         self::$CACHE[$key] = $rules;
         $rules = self::$CACHE[$key];
     }
     return $rules;
 }
コード例 #14
0
 /**
  * Returns the previous-or-same day-of-week adjuster, which adjusts the date to the
  * first occurrence of the specified day-of-week before the date being adjusted
  * unless it is already on that day in which case the same object is returned.
  * <p>
  * The ISO calendar system behaves as follows:<br>
  * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-10 (five days earlier).<br>
  * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-12 (three days earlier).<br>
  * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-15 (same as input).
  * <p>
  * The behavior is suitable for use with most calendar systems.
  * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit,
  * and assumes a seven day week.
  *
  * @param DayOfWeek $dayOfWeek the day-of-week to check for or move the date to, not null
  * @return TemporalAdjuster the previous-or-same day-of-week adjuster, not null
  */
 public static function previousOrSame(DayOfWeek $dayOfWeek)
 {
     $dowValue = $dayOfWeek->getValue();
     return self::fromCallable(function (Temporal $temporal) use($dowValue) {
         $calDow = $temporal->get(ChronoField::DAY_OF_WEEK());
         if ($calDow == $dowValue) {
             return $temporal;
         }
         $daysDiff = $dowValue - $calDow;
         return $temporal->minus($daysDiff >= 0 ? 7 - $daysDiff : -$daysDiff, ChronoUnit::DAYS());
     });
 }
コード例 #15
0
 public function test_getDayOfWeek()
 {
     $dow = DayOfWeek::MONDAY();
     foreach (Month::values() as $month) {
         $length = $month->length(false);
         for ($i = 1; $i <= $length; $i++) {
             $d = LocalDateTime::ofDateAndTime(LocalDate::ofMonth(2007, $month, $i), self::TEST_200707_15_12_30_40_987654321()->toLocalTime());
             $this->assertSame($d->getDayOfWeek(), $dow);
             $dow = $dow->plus(1);
         }
     }
 }
コード例 #16
0
ファイル: LocalDate.php プロジェクト: celest-time/prototype
 /**
  * Gets the day-of-week field, which is an enum {@code DayOfWeek}.
  * <p>
  * This method returns the enum {@link DayOfWeek} for the day-of-week.
  * This avoids confusion as to what {@code int} values mean.
  * If you need access to the primitive {@code int} value then the enum
  * provides the {@link DayOfWeek#getValue() int value}.
  * <p>
  * Additional information can be obtained from the {@code DayOfWeek}.
  * This includes textual names of the values.
  *
  * @return DayOfWeek the day-of-week, not null
  */
 public function getDayOfWeek()
 {
     $dow0 = Math::floorMod($this->toEpochDay() + 3, 7);
     return DayOfWeek::of($dow0 + 1);
 }
コード例 #17
0
 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()]];
 }
コード例 #18
0
 public function test_of()
 {
     //used for standard offset
     $stdOffset1 = ZoneOffset::UTC();
     $stdOffset2 = ZoneOffset::ofHours(1);
     $time_of_stdOffsetTransition1 = LocalDateTime::of(2013, 1, 5, 1, 0);
     $stdOffsetTransition1 = ZoneOffsetTransition::of($time_of_stdOffsetTransition1, $stdOffset1, $stdOffset2);
     $stdOffsetTransition_list = [];
     $stdOffsetTransition_list[] = $stdOffsetTransition1;
     //used for wall offset
     $wallOffset1 = ZoneOffset::ofHours(2);
     $wallOffset2 = ZoneOffset::ofHours(4);
     $wallOffset3 = ZoneOffset::ofHours(7);
     $time_of_wallOffsetTransition1 = LocalDateTime::of(2013, 2, 5, 1, 0);
     $time_of_wallOffsetTransition2 = LocalDateTime::of(2013, 3, 5, 1, 0);
     $time_of_wallOffsetTransition3 = LocalDateTime::of(2013, 10, 5, 1, 0);
     $wallOffsetTransition1 = ZoneOffsetTransition::of($time_of_wallOffsetTransition1, $wallOffset1, $wallOffset2);
     $wallOffsetTransition2 = ZoneOffsetTransition::of($time_of_wallOffsetTransition2, $wallOffset2, $wallOffset3);
     $wallOffsetTransition3 = ZoneOffsetTransition::of($time_of_wallOffsetTransition3, $wallOffset3, $wallOffset1);
     $wallOffsetTransition_list = [];
     $wallOffsetTransition_list[] = $wallOffsetTransition1;
     $wallOffsetTransition_list[] = $wallOffsetTransition2;
     $wallOffsetTransition_list[] = $wallOffsetTransition3;
     //used for ZoneOffsetTransitionRule
     $ruleOffset = ZoneOffset::ofHours(3);
     $timeDefinition = TimeDefinition::WALL();
     $rule1 = ZoneOffsetTransitionRule::of(Month::FEBRUARY(), 2, DayOfWeek::MONDAY(), LocalTime::of(1, 0), false, $timeDefinition, ZoneOffset::UTC(), ZoneOffset::UTC(), $ruleOffset);
     $rule_list = [];
     $rule_list[] = $rule1;
     //Begin verification
     $zoneRule = ZoneRules::of($stdOffset1, $wallOffset1, $stdOffsetTransition_list, $wallOffsetTransition_list, $rule_list);
     $before_time_of_stdOffsetTransition1 = OffsetDateTime::ofDateTime($time_of_stdOffsetTransition1, $stdOffset1)->minusSeconds(1);
     $after_time_of_stdOffsetTransition1 = OffsetDateTime::ofDateTime($time_of_stdOffsetTransition1, $stdOffset1)->plusSeconds(1);
     $this->assertEquals($zoneRule->getStandardOffset($before_time_of_stdOffsetTransition1->toInstant()), $stdOffset1);
     $this->assertEquals($zoneRule->getStandardOffset($after_time_of_stdOffsetTransition1->toInstant()), $stdOffset2);
     $before_time_of_wallOffsetTransition1 = OffsetDateTime::ofDateTime($time_of_wallOffsetTransition1, $wallOffset1)->minusSeconds(1);
     $after_time_of_wallOffsetTransition1 = OffsetDateTime::ofDateTime($time_of_wallOffsetTransition1, $wallOffset1)->plusSeconds(1);
     $this->assertEquals($zoneRule->nextTransition($before_time_of_wallOffsetTransition1->toInstant()), $wallOffsetTransition1);
     $this->assertEquals($zoneRule->nextTransition($after_time_of_wallOffsetTransition1->toInstant()), $wallOffsetTransition2);
     $before_time_of_wallOffsetTransition2 = OffsetDateTime::ofDateTime($time_of_wallOffsetTransition2, $wallOffset2)->minusSeconds(1);
     $after_time_of_wallOffsetTransition2 = OffsetDateTime::ofDateTime($time_of_wallOffsetTransition2, $wallOffset2)->plusSeconds(1);
     $this->assertEquals($zoneRule->nextTransition($before_time_of_wallOffsetTransition2->toInstant()), $wallOffsetTransition2);
     $this->assertEquals($zoneRule->nextTransition($after_time_of_wallOffsetTransition2->toInstant()), $wallOffsetTransition3);
     $before_time_of_wallOffsetTransition3 = OffsetDateTime::ofDateTime($time_of_wallOffsetTransition3, $wallOffset3)->minusSeconds(1);
     $after_time_of_wallOffsetTransition3 = OffsetDateTime::ofDateTime($time_of_wallOffsetTransition3, $wallOffset3)->plusSeconds(1);
     $this->assertEquals($zoneRule->nextTransition($before_time_of_wallOffsetTransition3->toInstant()), $wallOffsetTransition3);
     $this->assertEquals($zoneRule->nextTransition($after_time_of_wallOffsetTransition3->toInstant()), $rule1->createTransition(2014));
 }
コード例 #19
0
 /**
  * @dataProvider providerDayOfWeekData
  */
 public function test_parseDayOfWeekText(Locale $locale, $pattern, $input, DayOfWeek $expected)
 {
     $formatter = $this->getPatternFormatter($pattern)->withLocale($locale);
     $pos = new ParsePosition(0);
     $this->assertEquals(DayOfWeek::from($formatter->parsePos($input, $pos)), $expected);
     $this->assertEquals($pos->getIndex(), strlen($input));
 }