Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Calendar often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Calendar, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 39 | abstract class Calendar |
||
| 40 | { |
||
| 41 | const GREGORIAN = 'gregorian'; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var TranslationManager The translation manager instance. |
||
| 45 | * @since 0.11.0 |
||
| 46 | */ |
||
| 47 | protected $translationManager; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Returns the translation manager. |
||
| 51 | * |
||
| 52 | * @return TranslationManager The translation manager. |
||
| 53 | * |
||
| 54 | * @author Dominik del Bondio <[email protected]> |
||
| 55 | * @since 0.11.0 |
||
| 56 | */ |
||
| 57 | public function getTranslationManager() |
||
| 58 | { |
||
| 59 | return $this->translationManager; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Initialize the variables to default values. |
||
| 64 | * |
||
| 65 | * @author Dominik del Bondio <[email protected]> |
||
| 66 | * @author The ICU Project |
||
| 67 | * @since 0.11.0 |
||
| 68 | */ |
||
| 69 | protected function initVariables() |
||
| 70 | { |
||
| 71 | $this->fIsTimeSet = false; |
||
| 72 | $this->fAreFieldsInSync = false; |
||
| 73 | $this->fAreAllFieldsSet = false; |
||
| 74 | $this->fAreFieldsVirtuallySet = false; |
||
| 75 | $this->fNextStamp = self::kMinimumUserStamp; |
||
| 76 | $this->fTime = 0; |
||
|
|
|||
| 77 | $this->fLenient = true; |
||
| 78 | $this->fZone = null; |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Called by the overload handler in the constructor. |
||
| 83 | * |
||
| 84 | * @param TimeZone $zone The timezone to use. |
||
| 85 | * @param Locale $locale The locale to use. |
||
| 86 | * |
||
| 87 | * @author Dominik del Bondio <[email protected]> |
||
| 88 | * @author The ICU Project |
||
| 89 | * @since 0.11.0 |
||
| 90 | */ |
||
| 91 | protected function constructorOO(TimeZone $zone, Locale $locale) |
||
| 92 | { |
||
| 93 | $this->translationManager = $zone->getTranslationManager(); |
||
| 94 | $this->clear(); |
||
| 95 | $this->fZone = clone $zone; |
||
| 96 | $this->setWeekCountData($locale, null); |
||
| 97 | } |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Marker for end of resolve set (row or group). |
||
| 101 | */ |
||
| 102 | const RESOLVE_STOP = -1; |
||
| 103 | |||
| 104 | /** |
||
| 105 | * Value to be bitwised "ORed" against resolve table field values for |
||
| 106 | * remapping. Example: (UCAL_DATE | kResolveRemap) in 1st column will cause |
||
| 107 | * 'UCAL_DATE' to be returned, but will not examine the value of UCAL_DATE. |
||
| 108 | */ |
||
| 109 | const RESOLVE_REMAP = 32; |
||
| 110 | |||
| 111 | /** |
||
| 112 | * The minimum supported Julian day. This value is equivalent to |
||
| 113 | * MIN_MILLIS. |
||
| 114 | */ |
||
| 115 | const MIN_JULIAN = -19009842; // -0x7F000000; this was recalculated based on MIN_MILLIS |
||
| 116 | |||
| 117 | /** |
||
| 118 | * The minimum supported epoch milliseconds. This value is equivalent |
||
| 119 | * to MIN_JULIAN. |
||
| 120 | */ |
||
| 121 | const MIN_MILLIS = -1853317152000000.0; // ((MIN_JULIAN - kEpochStartAsJulianDay) * kOneDay) |
||
| 122 | |||
| 123 | /** |
||
| 124 | * The maximum supported Julian day. This value is equivalent to |
||
| 125 | * MAX_MILLIS. |
||
| 126 | */ |
||
| 127 | const MAX_JULIAN = 23939830.0; // (+0x7F000000) |
||
| 128 | |||
| 129 | /** |
||
| 130 | * The maximum supported epoch milliseconds. This value is equivalent |
||
| 131 | * to MAX_JULIAN. |
||
| 132 | */ |
||
| 133 | const MAX_MILLIS = 1857534508800000.0; // ((MAX_JULIAN - kEpochStartAsJulianDay) * kOneDay) |
||
| 134 | |||
| 135 | const LIMIT_MINIMUM = 0; |
||
| 136 | const LIMIT_GREATEST_MINIMUM = 1; |
||
| 137 | const LIMIT_LEAST_MAXIMUM = 2; |
||
| 138 | const LIMIT_MAXIMUM = 3; |
||
| 139 | const LIMIT_COUNT = 4; |
||
| 140 | |||
| 141 | protected static $kCalendarLimits = array( |
||
| 142 | // Minimum Greatest min Least max Greatest max |
||
| 143 | array( /*N/A*/-1, /*N/A*/-1, /*N/A*/-1, /*N/A*/-1 ), // ERA |
||
| 144 | array( /*N/A*/-1, /*N/A*/-1, /*N/A*/-1, /*N/A*/-1 ), // YEAR |
||
| 145 | array( /*N/A*/-1, /*N/A*/-1, /*N/A*/-1, /*N/A*/-1 ), // MONTH |
||
| 146 | array( /*N/A*/-1, /*N/A*/-1, /*N/A*/-1, /*N/A*/-1 ), // WEEK_OF_YEAR |
||
| 147 | array( /*N/A*/-1, /*N/A*/-1, /*N/A*/-1, /*N/A*/-1 ), // WEEK_OF_MONTH |
||
| 148 | array( /*N/A*/-1, /*N/A*/-1, /*N/A*/-1, /*N/A*/-1 ), // DAY_OF_MONTH |
||
| 149 | array( /*N/A*/-1, /*N/A*/-1, /*N/A*/-1, /*N/A*/-1 ), // DAY_OF_YEAR |
||
| 150 | array( 1, 1, 7, 7 ), // DAY_OF_WEEK |
||
| 151 | array( /*N/A*/-1, /*N/A*/-1, /*N/A*/-1, /*N/A*/-1 ), // DAY_OF_WEEK_IN_MONTH |
||
| 152 | array( 0, 0, 1, 1 ), // AM_PM |
||
| 153 | array( 0, 0, 11, 11 ), // HOUR |
||
| 154 | array( 0, 0, 23, 23 ), // HOUR_OF_DAY |
||
| 155 | array( 0, 0, 59, 59 ), // MINUTE |
||
| 156 | array( 0, 0, 59, 59 ), // SECOND |
||
| 157 | array( 0, 0, 999, 999 ), // MILLISECOND |
||
| 158 | // -12*self::kOneHour, -12*self::kOneHour, 12*self::kOneHour, 15*self::kOneHour |
||
| 159 | array( -43200000, -43200000, 43200000, 54000000 ), // ZONE_OFFSET |
||
| 160 | array( 0, 0,DateDefinitions::MILLIS_PER_HOUR , DateDefinitions::MILLIS_PER_HOUR ), // DST_OFFSET |
||
| 161 | array( /*N/A*/-1, /*N/A*/-1, /*N/A*/-1, /*N/A*/-1 ), // YEAR_WOY |
||
| 162 | array( 1, 1, 7, 7 ), // DOW_LOCAL |
||
| 163 | array( /*N/A*/-1, /*N/A*/-1, /*N/A*/-1, /*N/A*/-1 ), // EXTENDED_YEAR |
||
| 164 | array( self::MIN_JULIAN, self::MIN_JULIAN, self::MAX_JULIAN, self::MAX_JULIAN ), // JULIAN_DAY |
||
| 165 | // 0, 0, 24*self::kOneHour-1, 24*self::kOneHour-1 |
||
| 166 | array( 0, 0, 86399999, 86399999 ), // MILLISECONDS_IN_DAY |
||
| 167 | ); |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Returns the current UTC (GMT) time measured in milliseconds since 0:00:00 |
||
| 171 | * on 1/1/70 (derived from the system time). |
||
| 172 | * |
||
| 173 | * @return float The current UTC time in milliseconds. |
||
| 174 | * |
||
| 175 | * @author Dominik del Bondio <[email protected]> |
||
| 176 | * @author The ICU Project |
||
| 177 | * @since 0.11.0 |
||
| 178 | */ |
||
| 179 | public static function getNow() |
||
| 180 | { |
||
| 181 | return time() * DateDefinitions::MILLIS_PER_SECOND; |
||
| 182 | } |
||
| 183 | |||
| 184 | /** |
||
| 185 | * Gets this Calendar's time as milliseconds. May involve recalculation of |
||
| 186 | * time due to previous calls to set time field values. The time specified is |
||
| 187 | * non-local UTC (GMT) time. |
||
| 188 | * |
||
| 189 | * @return float The current time in UTC (GMT) time, or zero if the |
||
| 190 | * operation failed. |
||
| 191 | * |
||
| 192 | * @author Dominik del Bondio <[email protected]> |
||
| 193 | * @author The ICU Project |
||
| 194 | * @since 0.11.0 |
||
| 195 | */ |
||
| 196 | public function getTime() |
||
| 197 | { |
||
| 198 | return $this->getTimeInMillis(); |
||
| 199 | } |
||
| 200 | |||
| 201 | /** |
||
| 202 | * Sets this Calendar's current time with the given UDate. The time specified |
||
| 203 | * should be in non-local UTC (GMT) time. |
||
| 204 | * |
||
| 205 | * @param float The given UDate in UTC (GMT) time. |
||
| 206 | * |
||
| 207 | * @author Dominik del Bondio <[email protected]> |
||
| 208 | * @author The ICU Project |
||
| 209 | * @since 0.11.0 |
||
| 210 | */ |
||
| 211 | public function setTime($date) |
||
| 212 | { |
||
| 213 | $this->setTimeInMillis($date); |
||
| 214 | } |
||
| 215 | |||
| 216 | /** |
||
| 217 | * Returns the php native DateTime object which represents the time of this |
||
| 218 | * object. Also supports dates which are not in the range of a unix timestamp. |
||
| 219 | * It will also set the DateTime object to be in the same time zone as this |
||
| 220 | * Calendar object. |
||
| 221 | * Please note that this method will only work on PHP 5.1.x when you have |
||
| 222 | * explicitly enabled the new DateTime support. This restriction does not |
||
| 223 | * apply to 5.2 and upwards. |
||
| 224 | * When the Calendar object is in the AD era, the result of the conversion |
||
| 225 | * is undefined. |
||
| 226 | * |
||
| 227 | * @return \DateTime The native DateTime. |
||
| 228 | * |
||
| 229 | * @author Dominik del Bondio <[email protected]> |
||
| 230 | * @since 0.11.0 |
||
| 231 | */ |
||
| 232 | public function getNativeDateTime() |
||
| 233 | { |
||
| 234 | $dateTimeString = sprintf( |
||
| 235 | '%d-%d-%d %d:%d:%d', |
||
| 236 | $this->get(DateDefinitions::YEAR), $this->get(DateDefinitions::MONTH) + 1, $this->get(DateDefinitions::DATE), |
||
| 237 | $this->get(DateDefinitions::HOUR_OF_DAY), $this->get(DateDefinitions::MINUTE), $this->get(DateDefinitions::SECOND) |
||
| 238 | ); |
||
| 239 | |||
| 240 | $tz = $this->getTimeZone(); |
||
| 241 | // check if this is a custom timezone (they have GMT+0000 as id and could potentially contain seconds as well, so we allow up to 6 digits) |
||
| 242 | if (preg_match('#GMT[+-]\d{4,6}#', $tz->getId())) { |
||
| 243 | return new \DateTime($dateTimeString . $tz->formatOffset(false, '', '')); |
||
| 244 | } else { |
||
| 245 | return new \DateTime($dateTimeString, new \DateTimeZone($tz->getId())); |
||
| 246 | } |
||
| 247 | } |
||
| 248 | |||
| 249 | /** |
||
| 250 | * Gets this Calendar's time as unix timestamp. May involve recalculation of |
||
| 251 | * time due to previous calls to set time field values. The time specified is |
||
| 252 | * non-local UTC (GMT) time. |
||
| 253 | * |
||
| 254 | * @return int The current time in UTC (GMT) time as unix timestamp. |
||
| 255 | * |
||
| 256 | * @throws <b>OverflowException</b> when the date can't be represented by |
||
| 257 | * an unix timestamp. |
||
| 258 | * |
||
| 259 | * @author Dominik del Bondio <[email protected]> |
||
| 260 | * @since 0.11.0 |
||
| 261 | */ |
||
| 262 | public function getUnixTimestamp() |
||
| 263 | { |
||
| 264 | $unixTime = floor($this->getTimeInMillis() / DateDefinitions::MILLIS_PER_SECOND); |
||
| 265 | $unixTimeInt = (int) $unixTime; |
||
| 266 | // lets check if the int can't represent the time anymore |
||
| 267 | if ($unixTime != $unixTimeInt) { |
||
| 268 | throw new \OverflowException('cannot convert the date ' . $this->get(DateDefinitions::YEAR) . '/' . $this->get(DateDefinitions::MONTH) . '/' . $this->get(DateDefinitions::DATE) . ' into a unix timestamp'); |
||
| 269 | } |
||
| 270 | return $unixTimeInt; |
||
| 271 | } |
||
| 272 | |||
| 273 | /** |
||
| 274 | * Sets this Calendar's current time with the given unix timestamp. The time |
||
| 275 | * specified should be in non-local UTC (GMT) time. |
||
| 276 | * |
||
| 277 | * @param int $timestamp The given date in UTC (GMT) time. |
||
| 278 | * |
||
| 279 | * @author Dominik del Bondio <[email protected]> |
||
| 280 | * @since 0.11.0 |
||
| 281 | */ |
||
| 282 | public function setUnixTimestamp($timestamp) |
||
| 283 | { |
||
| 284 | $this->setTimeInMillis($timestamp * DateDefinitions::MILLIS_PER_SECOND); |
||
| 285 | } |
||
| 286 | |||
| 287 | /** |
||
| 288 | * @see Calendar::getAll() |
||
| 289 | * |
||
| 290 | * @author Dominik del Bondio <[email protected]> |
||
| 291 | * @since 1.0.0 |
||
| 292 | */ |
||
| 293 | public function toArray() |
||
| 294 | { |
||
| 295 | return $this->getAll(); |
||
| 296 | } |
||
| 297 | |||
| 298 | /** |
||
| 299 | * Sets all given time field values. |
||
| 300 | * |
||
| 301 | * @param array $data An array using the DateDefinitions::XXX as key |
||
| 302 | * and the respective value as value. |
||
| 303 | * |
||
| 304 | * @author Dominik del Bondio <[email protected]> |
||
| 305 | * @since 1.0.0 |
||
| 306 | */ |
||
| 307 | public function fromArray(array $data) |
||
| 308 | { |
||
| 309 | foreach ($data as $key => $value) { |
||
| 310 | $this->set1($key, $value); |
||
| 311 | } |
||
| 312 | } |
||
| 313 | |||
| 314 | /** |
||
| 315 | * Returns the locale option string containing the timezone option set |
||
| 316 | * to the timezone of this calendar. |
||
| 317 | * |
||
| 318 | * @param string $prefix The prefix which will be applied to the timezone option |
||
| 319 | * string. Use ';' here if you intend to use several |
||
| 320 | * locale options and append the result of this method |
||
| 321 | * to your locale string. |
||
| 322 | * |
||
| 323 | * @return string |
||
| 324 | * |
||
| 325 | * @author Dominik del Bondio <[email protected]> |
||
| 326 | * @since 1.0.0 |
||
| 327 | */ |
||
| 328 | public function getTimeZoneLocaleOptionString($prefix = '@') |
||
| 329 | { |
||
| 330 | return Locale::getTimeZoneOptionString($this, $prefix); |
||
| 331 | } |
||
| 332 | |||
| 333 | public function __is_equal(Calendar $that) |
||
| 334 | { |
||
| 335 | return $this->isEquivalentTo($that) && $this->getTimeInMillis() == $that->getTimeInMillis(); |
||
| 336 | } |
||
| 337 | |||
| 338 | public function __is_not_equal(Calendar $that) |
||
| 339 | { |
||
| 340 | return !$this->isEquivalentTo($that) || $this->getTimeInMillis() != $that->getTimeInMillis(); |
||
| 341 | } |
||
| 342 | |||
| 343 | /** |
||
| 344 | * Returns TRUE if the given Calendar object is equivalent to this |
||
| 345 | * one. An equivalent Calendar will behave exactly as this one |
||
| 346 | * does, but it may be set to a different time. By contrast, for |
||
| 347 | * the operator==() method to return TRUE, the other Calendar must |
||
| 348 | * be set to the same time. |
||
| 349 | * |
||
| 350 | * @param Calendar the Calendar to be compared with this Calendar |
||
| 351 | * |
||
| 352 | * @return bool |
||
| 353 | * |
||
| 354 | * @author Dominik del Bondio <[email protected]> |
||
| 355 | * @author The ICU Project |
||
| 356 | * @since 0.11.0 |
||
| 357 | */ |
||
| 358 | public function isEquivalentTo(Calendar $other) |
||
| 359 | { |
||
| 360 | return get_class($this) == get_class($other) && |
||
| 361 | $this->isLenient() == $other->isLenient() && |
||
| 362 | $this->getFirstDayOfWeek() == $other->getFirstDayOfWeek() && |
||
| 363 | $this->getMinimalDaysInFirstWeek() == $other->getMinimalDaysInFirstWeek() && |
||
| 364 | $this->getTimeZone()->__is_equal($other->getTimeZone()); |
||
| 365 | } |
||
| 366 | |||
| 367 | /** |
||
| 368 | * Compares the Calendar time, whereas Calendar::operator== compares the |
||
| 369 | * equality of Calendar objects. |
||
| 370 | * |
||
| 371 | * @param Calendar $when The Calendar to be compared with this Calendar. |
||
| 372 | * The object may be modified physically |
||
| 373 | * |
||
| 374 | * @return bool True if the current time of this Calendar is equal to the |
||
| 375 | * time of Calendar when; false otherwise. |
||
| 376 | * |
||
| 377 | * @author Dominik del Bondio <[email protected]> |
||
| 378 | * @author The ICU Project |
||
| 379 | * @since 0.11.0 |
||
| 380 | */ |
||
| 381 | public function equals(Calendar $when) |
||
| 385 | |||
| 386 | /** |
||
| 387 | * Returns true if this Calendar's current time is before "when"'s current |
||
| 388 | * time. |
||
| 389 | * |
||
| 390 | * @param Calendar $when The Calendar to be compared with this Calendar. |
||
| 391 | * The object may be modified physically. |
||
| 392 | * |
||
| 393 | * @return bool True if the current time of this Calendar is before the |
||
| 394 | * time of Calendar when; false otherwise. |
||
| 395 | * |
||
| 396 | * @author Dominik del Bondio <[email protected]> |
||
| 397 | * @author The ICU Project |
||
| 398 | * @since 0.11.0 |
||
| 399 | */ |
||
| 400 | public function before(Calendar $when) |
||
| 404 | |||
| 405 | /** |
||
| 406 | * Returns true if this Calendar's current time is after "when"'s current |
||
| 407 | * time. |
||
| 408 | * |
||
| 409 | * @param Calendar $when The Calendar to be compared with this Calendar. |
||
| 410 | * The object may be modified physically. |
||
| 411 | * |
||
| 412 | * @return bool True if the current time of this Calendar is after the |
||
| 413 | * time of Calendar when; false otherwise. |
||
| 414 | * |
||
| 415 | * @author Dominik del Bondio <[email protected]> |
||
| 416 | * @author The ICU Project |
||
| 417 | * @since 0.11.0 |
||
| 418 | */ |
||
| 419 | public function after(Calendar $when) |
||
| 423 | |||
| 424 | /** |
||
| 425 | * UDate Arithmetic function. Adds the specified (signed) amount of time to |
||
| 426 | * the given time field, based on the calendar's rules. For example, to |
||
| 427 | * subtract 5 days from the current time of the calendar, call |
||
| 428 | * add(DateDefinitions::DATE, -5). When adding on the month or |
||
| 429 | * DateDefinitions::DATE field, other fields like date might conflict |
||
| 430 | * and need to be changed. For instance, adding 1 month on the date 01/31/96 |
||
| 431 | * will result in 02/29/96. |
||
| 432 | * |
||
| 433 | * @param int $field Specifies which date field to modify. |
||
| 434 | * @param int $amount The amount of time to be added to the field, in the natural |
||
| 435 | * unit for that field (e.g., days for the day fields, hours |
||
| 436 | * for the hour field.) |
||
| 437 | * |
||
| 438 | * @author Dominik del Bondio <[email protected]> |
||
| 439 | * @author The ICU Project |
||
| 440 | * @since 0.11.0 |
||
| 441 | */ |
||
| 442 | public function add($field, $amount) |
||
| 561 | |||
| 562 | /** |
||
| 563 | * Time Field Rolling function. Rolls by the given amount on the given |
||
| 564 | * time field. For example, to roll the current date up by one day, call |
||
| 565 | * roll(DateDefinitions::DATE, +1). When rolling on the month or |
||
| 566 | * DateDefinitions::MONTH field, other fields like date might |
||
| 567 | * conflict and, need to be changed. For instance, rolling the month up on the |
||
| 568 | * date 01/31/96 will result in 02/29/96. Rolling by a positive value always |
||
| 569 | * means rolling forward in time; e.g., rolling the year by +1 on "100 BC" |
||
| 570 | * will result in "99 BC", for Gregorian calendar. When rolling on the |
||
| 571 | * hour-in-day or DateDefinitions::HOUR_OF_DAY field, it will |
||
| 572 | * roll the hour value in the range between 0 and 23, which is zero-based. |
||
| 573 | * <P> |
||
| 574 | * The only difference between roll() and add() is that roll() does not change |
||
| 575 | * the value of more significant fields when it reaches the minimum or maximum |
||
| 576 | * of its range, whereas add() does. |
||
| 577 | * |
||
| 578 | * @param int $field The time field. |
||
| 579 | * @param int $amount Indicates amount to roll. |
||
| 580 | * |
||
| 581 | * @author Dominik del Bondio <[email protected]> |
||
| 582 | * @author The ICU Project |
||
| 583 | * @since 0.11.0 |
||
| 584 | */ |
||
| 585 | public function roll($field, $amount) |
||
| 905 | |||
| 906 | /** |
||
| 907 | * Return the difference between the given time and the time this |
||
| 908 | * calendar object is set to. If this calendar is set |
||
| 909 | * <em>before</em> the given time, the returned value will be |
||
| 910 | * positive. If this calendar is set <em>after</em> the given |
||
| 911 | * time, the returned value will be negative. The |
||
| 912 | * <code>field</code> parameter specifies the units of the return |
||
| 913 | * value. For example, if <code>fieldDifference($when, |
||
| 914 | * DateDefinitions::MONTH)</code> returns 3, then this calendar is set to |
||
| 915 | * 3 months before <code>when</code>, and possibly some addition |
||
| 916 | * time less than one month. |
||
| 917 | * |
||
| 918 | * <p>As a side effect of this call, this calendar is advanced |
||
| 919 | * toward <code>$when</code> by the given amount. That is, calling |
||
| 920 | * this method has the side effect of calling <code>add($field, |
||
| 921 | * $n)</code>, where <code>n</code> is the return value. |
||
| 922 | * |
||
| 923 | * <p>Usage: To use this method, call it first with the largest |
||
| 924 | * field of interest, then with progressively smaller fields. For |
||
| 925 | * example: |
||
| 926 | * |
||
| 927 | * <pre> |
||
| 928 | * $y = $cal->fieldDifference($when, DateDefinitions::YEAR); |
||
| 929 | * $m = $cal->fieldDifference($when, DateDefinitions::MONTH); |
||
| 930 | * $d = $cal->fieldDifference($when, DateDefinitions::DATE);</pre> |
||
| 931 | * |
||
| 932 | * computes the difference between <code>$cal</code> and |
||
| 933 | * <code>$when</code> in years, months, and days. |
||
| 934 | * |
||
| 935 | * <p>Note: <code>fieldDifference()</code> is |
||
| 936 | * <em>asymmetrical</em>. That is, in the following code: |
||
| 937 | * |
||
| 938 | * <pre> |
||
| 939 | * $cal->setTime($date1); |
||
| 940 | * $m1 = $cal->fieldDifference($date2, DateDefinitions::MONTH); |
||
| 941 | * $d1 = $cal->fieldDifference($date2, DateDefinitions::DATE); |
||
| 942 | * $cal->setTime($date2); |
||
| 943 | * $m2 = $cal->fieldDifference($date1, DateDefinitions::MONTH); |
||
| 944 | * $d2 = $cal->fieldDifference($date1, DateDefinitions::DATE);</pre> |
||
| 945 | * |
||
| 946 | * one might expect that <code>$m1 == -$m2 && $d1 == -$d2</code>. |
||
| 947 | * However, this is not generally the case, because of |
||
| 948 | * irregularities in the underlying calendar system (e.g., the |
||
| 949 | * Gregorian calendar has a varying number of days per month). |
||
| 950 | * |
||
| 951 | * @param float|Calendar $targetMs When the date to compare this |
||
| 952 | * calendar's time to |
||
| 953 | * @param int $field The field in which to compute the result |
||
| 954 | * |
||
| 955 | * @return int The difference, either positive or negative, between |
||
| 956 | * this calendar's time and <code>when</code>, in terms |
||
| 957 | * of <code>field</code>. |
||
| 958 | * |
||
| 959 | * @author Dominik del Bondio <[email protected]> |
||
| 960 | * @author The ICU Project |
||
| 961 | * @since 0.11.0 |
||
| 962 | */ |
||
| 963 | public function fieldDifference($targetMs /* $when */, $field) |
||
| 1051 | |||
| 1052 | /** |
||
| 1053 | * Sets the calendar's time zone to be the same as the one passed in. The |
||
| 1054 | * TimeZone passed in is _not_ cloned. |
||
| 1055 | * |
||
| 1056 | * @param TimeZone $zone The given time zone. If null is passed nothing |
||
| 1057 | * is done. |
||
| 1058 | * |
||
| 1059 | * @author Dominik del Bondio <[email protected]> |
||
| 1060 | * @author The ICU Project |
||
| 1061 | * @since 0.11.0 |
||
| 1062 | */ |
||
| 1063 | public function setTimeZone(TimeZone $zone = null) |
||
| 1076 | |||
| 1077 | /** |
||
| 1078 | * Returns a reference to the time zone owned by this calendar. |
||
| 1079 | * |
||
| 1080 | * @return TimeZone The time zone object associated with this |
||
| 1081 | * calendar. |
||
| 1082 | * |
||
| 1083 | * @author Dominik del Bondio <[email protected]> |
||
| 1084 | * @author The ICU Project |
||
| 1085 | * @since 0.11.0 |
||
| 1086 | */ |
||
| 1087 | public function getTimeZone() |
||
| 1091 | |||
| 1092 | /** |
||
| 1093 | * Queries if the current date for this Calendar is in Daylight Savings Time. |
||
| 1094 | * |
||
| 1095 | * @return bool True if the current date for this Calendar is in |
||
| 1096 | * Daylight Savings Time, false, otherwise. |
||
| 1097 | * |
||
| 1098 | * @author Dominik del Bondio <[email protected]> |
||
| 1099 | * @author The ICU Project |
||
| 1100 | * @since 0.11.0 |
||
| 1101 | */ |
||
| 1102 | abstract public function inDaylightTime(); |
||
| 1103 | |||
| 1104 | /** |
||
| 1105 | * Specifies whether or not date/time interpretation is to be lenient. With |
||
| 1106 | * lenient interpretation, a date such as "February 942, 1996" will be treated |
||
| 1107 | * as being equivalent to the 941st day after February 1, 1996. With strict |
||
| 1108 | * interpretation, such dates will cause an error when computing time from the |
||
| 1109 | * time field values representing the dates. |
||
| 1110 | * |
||
| 1111 | * @param bool $lenient True specifies date/time interpretation to be lenient. |
||
| 1112 | * |
||
| 1113 | * @author Dominik del Bondio <[email protected]> |
||
| 1114 | * @author The ICU Project |
||
| 1115 | * @since 0.11.0 |
||
| 1116 | */ |
||
| 1117 | public function setLenient($lenient) |
||
| 1121 | |||
| 1122 | /** |
||
| 1123 | * Tells whether date/time interpretation is to be lenient. |
||
| 1124 | * |
||
| 1125 | * @return bool True tells that date/time interpretation is to be lenient. |
||
| 1126 | * |
||
| 1127 | * @author Dominik del Bondio <[email protected]> |
||
| 1128 | * @author The ICU Project |
||
| 1129 | * @since 0.11.0 |
||
| 1130 | */ |
||
| 1131 | public function isLenient() |
||
| 1135 | |||
| 1136 | /** |
||
| 1137 | * Sets what the first day of the week is; e.g., Sunday in US, Monday in |
||
| 1138 | * France. |
||
| 1139 | * |
||
| 1140 | * @param int $value The given first day of the week. |
||
| 1141 | * |
||
| 1142 | * @author Dominik del Bondio <[email protected]> |
||
| 1143 | * @author The ICU Project |
||
| 1144 | * @since 0.11.0 |
||
| 1145 | */ |
||
| 1146 | public function setFirstDayOfWeek($value) |
||
| 1150 | |||
| 1151 | /** |
||
| 1152 | * Gets what the first day of the week is; e.g., Sunday in US, Monday in |
||
| 1153 | * France. |
||
| 1154 | * |
||
| 1155 | * @return int The first day of the week. |
||
| 1156 | * |
||
| 1157 | * @author Dominik del Bondio <[email protected]> |
||
| 1158 | * @author The ICU Project |
||
| 1159 | * @since 0.11.0 |
||
| 1160 | */ |
||
| 1161 | public function getFirstDayOfWeek() |
||
| 1165 | |||
| 1166 | /** |
||
| 1167 | * Sets what the minimal days required in the first week of the year are; For |
||
| 1168 | * example, if the first week is defined as one that contains the first day of |
||
| 1169 | * the first month of a year, call the method with value 1. If it must be a |
||
| 1170 | * full week, use value 7. |
||
| 1171 | * |
||
| 1172 | * @param int $value The given minimal days required in the first week of the |
||
| 1173 | * year. |
||
| 1174 | * |
||
| 1175 | * @author Dominik del Bondio <[email protected]> |
||
| 1176 | * @author The ICU Project |
||
| 1177 | * @since 0.11.0 |
||
| 1178 | */ |
||
| 1179 | public function setMinimalDaysInFirstWeek($value) |
||
| 1183 | |||
| 1184 | /** |
||
| 1185 | * Gets what the minimal days required in the first week of the year are; |
||
| 1186 | * e.g., if the first week is defined as one that contains the first day of |
||
| 1187 | * the first month of a year, getMinimalDaysInFirstWeek returns 1. If the |
||
| 1188 | * minimal days required must be a full week, getMinimalDaysInFirstWeek |
||
| 1189 | * returns 7. |
||
| 1190 | * |
||
| 1191 | * @return int The minimal days required in the first week of the year. |
||
| 1192 | * |
||
| 1193 | * @author Dominik del Bondio <[email protected]> |
||
| 1194 | * @author The ICU Project |
||
| 1195 | * @since 0.11.0 |
||
| 1196 | */ |
||
| 1197 | public function getMinimalDaysInFirstWeek() |
||
| 1201 | |||
| 1202 | /** |
||
| 1203 | * Gets the minimum value for the given time field. e.g., for Gregorian |
||
| 1204 | * DAY_OF_MONTH, 1. |
||
| 1205 | * |
||
| 1206 | * @param int $field The given time field. |
||
| 1207 | * |
||
| 1208 | * @return int The minimum value for the given time field. |
||
| 1209 | * |
||
| 1210 | * @author Dominik del Bondio <[email protected]> |
||
| 1211 | * @author The ICU Project |
||
| 1212 | * @since 0.11.0 |
||
| 1213 | */ |
||
| 1214 | public function getMinimum($field) |
||
| 1218 | |||
| 1219 | /** |
||
| 1220 | * Gets the maximum value for the given time field. e.g., for Gregorian |
||
| 1221 | * DAY_OF_MONTH, 31. |
||
| 1222 | * |
||
| 1223 | * @param int $field The given time field. |
||
| 1224 | * |
||
| 1225 | * @return int The maximum value for the given time field. |
||
| 1226 | * |
||
| 1227 | * @author Dominik del Bondio <[email protected]> |
||
| 1228 | * @author The ICU Project |
||
| 1229 | * @since 0.11.0 |
||
| 1230 | */ |
||
| 1231 | public function getMaximum($field) |
||
| 1235 | |||
| 1236 | /** |
||
| 1237 | * Gets the highest minimum value for the given field if varies. Otherwise |
||
| 1238 | * same as getMinimum(). For Gregorian, no difference. |
||
| 1239 | * |
||
| 1240 | * @param int $field The given time field. |
||
| 1241 | * |
||
| 1242 | * @return int The highest minimum value for the given time field. |
||
| 1243 | * |
||
| 1244 | * @author Dominik del Bondio <[email protected]> |
||
| 1245 | * @author The ICU Project |
||
| 1246 | * @since 0.11.0 |
||
| 1247 | */ |
||
| 1248 | public function getGreatestMinimum($field) |
||
| 1252 | |||
| 1253 | /** |
||
| 1254 | * Gets the lowest maximum value for the given field if varies. Otherwise same |
||
| 1255 | * as getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28. |
||
| 1256 | * |
||
| 1257 | * @param int $field The given time field. |
||
| 1258 | * |
||
| 1259 | * @return int The lowest maximum value for the given time field. |
||
| 1260 | * |
||
| 1261 | * @author Dominik del Bondio <[email protected]> |
||
| 1262 | * @author The ICU Project |
||
| 1263 | * @since 0.11.0 |
||
| 1264 | */ |
||
| 1265 | public function getLeastMaximum($field) |
||
| 1269 | |||
| 1270 | /** |
||
| 1271 | * Return the minimum value that this field could have, given the current |
||
| 1272 | * date. For the Gregorian calendar, this is the same as getMinimum() and |
||
| 1273 | * getGreatestMinimum(). |
||
| 1274 | * |
||
| 1275 | * The version of this function on Calendar uses an iterative algorithm to |
||
| 1276 | * determine the actual minimum value for the field. There is almost always a |
||
| 1277 | * more efficient way to accomplish this (in most cases, you can simply return |
||
| 1278 | * getMinimum()). GregorianCalendar overrides this function with a more |
||
| 1279 | * efficient implementation. |
||
| 1280 | * |
||
| 1281 | * @param int $field the field to determine the minimum of |
||
| 1282 | * |
||
| 1283 | * @return int the minimum of the given field for the current date of |
||
| 1284 | * this Calendar |
||
| 1285 | * |
||
| 1286 | * @author Dominik del Bondio <[email protected]> |
||
| 1287 | * @author The ICU Project |
||
| 1288 | * @since 0.11.0 |
||
| 1289 | */ |
||
| 1290 | public function getActualMinimum($field) |
||
| 1322 | |||
| 1323 | /** |
||
| 1324 | * Return the maximum value that this field could have, given the current |
||
| 1325 | * date. For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, |
||
| 1326 | * the actual maximum would be 28; for "Feb 3, 1996" it s 29. Similarly for a |
||
| 1327 | * Hebrew calendar,for some years the actual maximum for MONTH is 12, and for |
||
| 1328 | * others 13. |
||
| 1329 | * |
||
| 1330 | * The version of this function on Calendar uses an iterative algorithm to |
||
| 1331 | * determine the actual maximum value for the field. There is almost always a |
||
| 1332 | * more efficient way to accomplish this (in most cases, you can simply return |
||
| 1333 | * getMaximum()). AgaviGregorianCalendar overrides this function with a more |
||
| 1334 | * efficient implementation. |
||
| 1335 | * |
||
| 1336 | * @param int $field the field to determine the maximum of |
||
| 1337 | * |
||
| 1338 | * @return int the maximum of the given field for the current date of |
||
| 1339 | * this Calendar |
||
| 1340 | * |
||
| 1341 | * @author Dominik del Bondio <[email protected]> |
||
| 1342 | * @author The ICU Project |
||
| 1343 | * @since 0.11.0 |
||
| 1344 | */ |
||
| 1345 | public function getActualMaximum($field) |
||
| 1383 | |||
| 1384 | /** |
||
| 1385 | * Gets all time field values. Recalculate the current time field |
||
| 1386 | * values if the time value has been changed by a call to setTime(). Return |
||
| 1387 | * zero for unset fields if any fields have been explicitly set by a call to |
||
| 1388 | * set(). To force a recomputation of all fields regardless of the previous |
||
| 1389 | * state, call complete(). |
||
| 1390 | * |
||
| 1391 | * @return array All fields of this instance. |
||
| 1392 | * |
||
| 1393 | * @author Dominik del Bondio <[email protected]> |
||
| 1394 | * @author The ICU Project |
||
| 1395 | * @since 0.11.0 |
||
| 1396 | */ |
||
| 1397 | public function getAll() |
||
| 1405 | |||
| 1406 | /** |
||
| 1407 | * Gets the value for a given time field. Recalculate the current time field |
||
| 1408 | * values if the time value has been changed by a call to setTime(). Return |
||
| 1409 | * zero for unset fields if any fields have been explicitly set by a call to |
||
| 1410 | * set(). To force a recomputation of all fields regardless of the previous |
||
| 1411 | * state, call complete(). |
||
| 1412 | * |
||
| 1413 | * @param int $field The given time field. |
||
| 1414 | * |
||
| 1415 | * @return int The value for the given time field, or zero if the field |
||
| 1416 | * is unset, and set() has been called for any other field. |
||
| 1417 | * |
||
| 1418 | * @author Dominik del Bondio <[email protected]> |
||
| 1419 | * @author The ICU Project |
||
| 1420 | * @since 0.11.0 |
||
| 1421 | */ |
||
| 1422 | public function get($field) |
||
| 1430 | |||
| 1431 | /** |
||
| 1432 | * Determines if the given time field has a value set. This can affect in the |
||
| 1433 | * resolving of time in Calendar. Unset fields have a value of zero, by |
||
| 1434 | * definition. |
||
| 1435 | * |
||
| 1436 | * @param int $field The given time field. |
||
| 1437 | * |
||
| 1438 | * @return bool True if the given time field has a value set; false |
||
| 1439 | * otherwise. |
||
| 1440 | * |
||
| 1441 | * @author Dominik del Bondio <[email protected]> |
||
| 1442 | * @author The ICU Project |
||
| 1443 | * @since 0.11.0 |
||
| 1444 | */ |
||
| 1445 | public function _isSet($field) // isset is a keyword in php |
||
| 1449 | |||
| 1450 | /** |
||
| 1451 | * Overloaded |
||
| 1452 | * |
||
| 1453 | * @see Calendar::set1() |
||
| 1454 | * @see Calendar::set2() |
||
| 1455 | * @see Calendar::set3() |
||
| 1456 | * @see Calendar::set4() |
||
| 1457 | * |
||
| 1458 | * @author Dominik del Bondio <[email protected]> |
||
| 1459 | * @author The ICU Project |
||
| 1460 | * @since 0.11.0 |
||
| 1461 | */ |
||
| 1462 | public function set() |
||
| 1480 | |||
| 1481 | /** |
||
| 1482 | * Sets the given time field with the given value. |
||
| 1483 | * |
||
| 1484 | * @param int $field The given time field. |
||
| 1485 | * @param int $value The value to be set for the given time field. |
||
| 1486 | * |
||
| 1487 | * @author Dominik del Bondio <[email protected]> |
||
| 1488 | * @author The ICU Project |
||
| 1489 | * @since 0.11.0 |
||
| 1490 | */ |
||
| 1491 | View Code Duplication | public function set1($field, $value) |
|
| 1502 | |||
| 1503 | /** |
||
| 1504 | * Sets the values for the fields YEAR, MONTH, and DATE. Other field values |
||
| 1505 | * are retained; call clear() first if this is not desired. |
||
| 1506 | * |
||
| 1507 | * @param int $year The value used to set the YEAR time field. |
||
| 1508 | * @param int $month The value used to set the MONTH time field. Month value is |
||
| 1509 | * 0-based. e.g., 0 for January. |
||
| 1510 | * @param int $date The value used to set the DATE time field. |
||
| 1511 | * |
||
| 1512 | * @author Dominik del Bondio <[email protected]> |
||
| 1513 | * @author The ICU Project |
||
| 1514 | * @since 0.11.0 |
||
| 1515 | */ |
||
| 1516 | public function set2($year, $month, $date) |
||
| 1522 | |||
| 1523 | /** |
||
| 1524 | * Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, and MINUTE. |
||
| 1525 | * Other field values are retained; call |
||
| 1526 | * ) first if this is not desired. |
||
| 1527 | * |
||
| 1528 | * @param int $year The value used to set the YEAR time field. |
||
| 1529 | * @param int $month The value used to set the MONTH time field. Month value is |
||
| 1530 | * 0-based. E.g., 0 for January. |
||
| 1531 | * @param int $date The value used to set the DATE time field. |
||
| 1532 | * @param int $hour The value used to set the HOUR_OF_DAY time field. |
||
| 1533 | * @param int $minute The value used to set the MINUTE time field. |
||
| 1534 | * |
||
| 1535 | * @author Dominik del Bondio <[email protected]> |
||
| 1536 | * @author The ICU Project |
||
| 1537 | * @since 0.11.0 |
||
| 1538 | */ |
||
| 1539 | View Code Duplication | public function set3($year, $month, $date, $hour, $minute) |
|
| 1547 | |||
| 1548 | /** |
||
| 1549 | * Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, MINUTE, and |
||
| 1550 | * SECOND. Other field values are retained; call clear() first if this is not |
||
| 1551 | * desired. |
||
| 1552 | * |
||
| 1553 | * @param int $year The value used to set the YEAR time field. |
||
| 1554 | * @param int $month The value used to set the MONTH time field. Month value is |
||
| 1555 | * 0-based. E.g., 0 for January. |
||
| 1556 | * @param int $date The value used to set the DATE time field. |
||
| 1557 | * @param int $hour The value used to set the HOUR_OF_DAY time field. |
||
| 1558 | * @param int $minute The value used to set the MINUTE time field. |
||
| 1559 | * @param int $second The value used to set the SECOND time field. |
||
| 1560 | * |
||
| 1561 | * @author Dominik del Bondio <[email protected]> |
||
| 1562 | * @author The ICU Project |
||
| 1563 | * @since 0.11.0 |
||
| 1564 | */ |
||
| 1565 | View Code Duplication | public function set4($year, $month, $date, $hour, $minute, $second) |
|
| 1574 | |||
| 1575 | /** |
||
| 1576 | * Overloaded |
||
| 1577 | * |
||
| 1578 | * @see Calendar::clear1() |
||
| 1579 | * @see Calendar::clear2() |
||
| 1580 | * |
||
| 1581 | * @author Dominik del Bondio <[email protected]> |
||
| 1582 | * @author The ICU Project |
||
| 1583 | * @since 0.11.0 |
||
| 1584 | */ |
||
| 1585 | public function clear() |
||
| 1599 | |||
| 1600 | /** |
||
| 1601 | * Clears the values of all the time fields, making them both unset and |
||
| 1602 | * assigning them a value of zero. The field values will be determined during |
||
| 1603 | * the next resolving of time into time fields. |
||
| 1604 | * |
||
| 1605 | * @author Dominik del Bondio <[email protected]> |
||
| 1606 | * @author The ICU Project |
||
| 1607 | * @since 0.11.0 |
||
| 1608 | */ |
||
| 1609 | public function clear1() |
||
| 1619 | |||
| 1620 | /** |
||
| 1621 | * Clears the value in the given time field, both making it unset and |
||
| 1622 | * assigning it a value of zero. This field value will be determined during |
||
| 1623 | * the next resolving of time into time fields. |
||
| 1624 | * |
||
| 1625 | * @param string $field The time field to be cleared. |
||
| 1626 | * |
||
| 1627 | * @author Dominik del Bondio <[email protected]> |
||
| 1628 | * @author The ICU Project |
||
| 1629 | * @since 0.11.0 |
||
| 1630 | */ |
||
| 1631 | View Code Duplication | public function clear2($field) |
|
| 1641 | |||
| 1642 | /** |
||
| 1643 | * Converts Calendar's time field values to GMT as milliseconds. |
||
| 1644 | * |
||
| 1645 | * @author Dominik del Bondio <[email protected]> |
||
| 1646 | * @author The ICU Project |
||
| 1647 | * @since 0.11.0 |
||
| 1648 | */ |
||
| 1649 | protected function computeTime() |
||
| 1696 | |||
| 1697 | /** |
||
| 1698 | * Converts GMT as milliseconds to time field values. This allows you to sync |
||
| 1699 | * up the time field values with a new time that is set for the calendar. |
||
| 1700 | * This method does NOT recompute the time first; to recompute the time, then |
||
| 1701 | * the fields, use the method complete(). |
||
| 1702 | * |
||
| 1703 | * @author Dominik del Bondio <[email protected]> |
||
| 1704 | * @author The ICU Project |
||
| 1705 | * @since 0.11.0 |
||
| 1706 | */ |
||
| 1707 | protected function computeFields() |
||
| 1804 | |||
| 1805 | /** |
||
| 1806 | * Gets this Calendar's current time as a long. |
||
| 1807 | * |
||
| 1808 | * @return double the current time as UTC milliseconds from the epoch. |
||
| 1809 | * |
||
| 1810 | * @author Dominik del Bondio <[email protected]> |
||
| 1811 | * @author The ICU Project |
||
| 1812 | * @since 0.11.0 |
||
| 1813 | */ |
||
| 1814 | protected function getTimeInMillis() |
||
| 1822 | |||
| 1823 | /** |
||
| 1824 | * Sets this Calendar's current time from the given long value. |
||
| 1825 | * |
||
| 1826 | * @param double $millis the new time in UTC milliseconds from the epoch. |
||
| 1827 | * |
||
| 1828 | * @author Dominik del Bondio <[email protected]> |
||
| 1829 | * @author The ICU Project |
||
| 1830 | * @since 0.11.0 |
||
| 1831 | */ |
||
| 1832 | protected function setTimeInMillis($millis) |
||
| 1846 | |||
| 1847 | /** |
||
| 1848 | * Recomputes the current time from currently set fields, and then fills in |
||
| 1849 | * any unset fields in the time field list. |
||
| 1850 | * |
||
| 1851 | * @author Dominik del Bondio <[email protected]> |
||
| 1852 | * @author The ICU Project |
||
| 1853 | * @since 0.11.0 |
||
| 1854 | */ |
||
| 1855 | protected function complete() |
||
| 1868 | |||
| 1869 | /** |
||
| 1870 | * Gets the value for a given time field. Subclasses can use this function to |
||
| 1871 | * get field values without forcing recomputation of time. If the field's |
||
| 1872 | * stamp is UNSET, the defaultValue is used. |
||
| 1873 | * |
||
| 1874 | * @param int $field The given time field. |
||
| 1875 | * @param int $defaultValue a default value used if the field is unset. |
||
| 1876 | * @return int The value for the given time field. |
||
| 1877 | * |
||
| 1878 | * @author Dominik del Bondio <[email protected]> |
||
| 1879 | * @author The ICU Project |
||
| 1880 | * @since 0.11.0 |
||
| 1881 | */ |
||
| 1882 | protected function internalGet($field, $defaultValue = null) |
||
| 1886 | |||
| 1887 | /** |
||
| 1888 | * Sets the value for a given time field. This is a fast internal method for |
||
| 1889 | * subclasses. It does not affect the fAreFieldsInSync, isTimeSet, or |
||
| 1890 | * areAllFieldsSet flags. |
||
| 1891 | * |
||
| 1892 | * @param int $field The given time field. |
||
| 1893 | * @param int $value The value for the given time field. |
||
| 1894 | * |
||
| 1895 | * @author Dominik del Bondio <[email protected]> |
||
| 1896 | * @author The ICU Project |
||
| 1897 | * @since 0.11.0 |
||
| 1898 | */ |
||
| 1899 | protected function internalSet($field, $value) |
||
| 1905 | |||
| 1906 | /** |
||
| 1907 | * Prepare this calendar for computing the actual minimum or maximum. |
||
| 1908 | * This method modifies this calendar's fields; it is called on a |
||
| 1909 | * temporary calendar. |
||
| 1910 | * |
||
| 1911 | * @param int $field The given time field |
||
| 1912 | * @param bool $isMinimum |
||
| 1913 | * |
||
| 1914 | * @author Dominik del Bondio <[email protected]> |
||
| 1915 | * @author The ICU Project |
||
| 1916 | * @since 0.11.0 |
||
| 1917 | */ |
||
| 1918 | protected function prepareGetActual($field, $isMinimum) |
||
| 1963 | |||
| 1964 | /** |
||
| 1965 | * Subclass API for defining limits of different types. |
||
| 1966 | * Subclasses must implement this method to return limits for the |
||
| 1967 | * following fields: |
||
| 1968 | * |
||
| 1969 | * <pre>DateDefinitions::ERA |
||
| 1970 | * DateDefinitions::YEAR |
||
| 1971 | * DateDefinitions::MONTH |
||
| 1972 | * DateDefinitions::WEEK_OF_YEAR |
||
| 1973 | * DateDefinitions::WEEK_OF_MONTH |
||
| 1974 | * DateDefinitions::DATE |
||
| 1975 | * DateDefinitions::DAY_OF_YEAR |
||
| 1976 | * DateDefinitions::DAY_OF_WEEK_IN_MONTH |
||
| 1977 | * DateDefinitions::YEAR_WOY |
||
| 1978 | * DateDefinitions::EXTENDED_YEAR</pre> |
||
| 1979 | * |
||
| 1980 | * @param int $field one of the above field numbers |
||
| 1981 | * @param int $limitType one of <code>self::LIMIT_MINIMUM</code>, |
||
| 1982 | * <code>self::LIMIT_GREATEST_MINIMUM</code>, |
||
| 1983 | * <code>self::LIMIT_LEAST_MAXIMUM</code>, |
||
| 1984 | * or <code>self::LIMIT_MAXIMUM</code> |
||
| 1985 | * |
||
| 1986 | * @return int |
||
| 1987 | * |
||
| 1988 | * @author Dominik del Bondio <[email protected]> |
||
| 1989 | * @author The ICU Project |
||
| 1990 | * @since 0.11.0 |
||
| 1991 | */ |
||
| 1992 | abstract protected function handleGetLimit($field, $limitType); |
||
| 1993 | |||
| 1994 | /** |
||
| 1995 | * Return a limit for a field. |
||
| 1996 | * |
||
| 1997 | * @param int $field the field |
||
| 1998 | * @param int $limitType the type specifier for the limit |
||
| 1999 | * |
||
| 2000 | * @return int |
||
| 2001 | * |
||
| 2002 | * @author Dominik del Bondio <[email protected]> |
||
| 2003 | * @author The ICU Project |
||
| 2004 | * @since 0.11.0 |
||
| 2005 | */ |
||
| 2006 | protected function getLimit($field, $limitType) |
||
| 2026 | |||
| 2027 | /** |
||
| 2028 | * Return the Julian day number of day before the first day of the |
||
| 2029 | * given month in the given extended year. Subclasses should override |
||
| 2030 | * this method to implement their calendar system. |
||
| 2031 | * |
||
| 2032 | * @param int $eyear the extended year |
||
| 2033 | * @param int $month the zero-based month, or 0 if useMonth is false |
||
| 2034 | * @param bool $useMonth if false, compute the day before the first day of |
||
| 2035 | * the given year, otherwise, compute the day before the |
||
| 2036 | * first day of the given month |
||
| 2037 | * |
||
| 2038 | * @return int the Julian day number of the day before the first |
||
| 2039 | * day of the given month and year |
||
| 2040 | * |
||
| 2041 | * @author Dominik del Bondio <[email protected]> |
||
| 2042 | * @author The ICU Project |
||
| 2043 | * @since 0.11.0 |
||
| 2044 | */ |
||
| 2045 | abstract protected function handleComputeMonthStart($eyear, $month, $useMonth); |
||
| 2046 | |||
| 2047 | /** |
||
| 2048 | * Return the number of days in the given month of the given extended |
||
| 2049 | * year of this calendar system. Subclasses should override this |
||
| 2050 | * method if they can provide a more correct or more efficient |
||
| 2051 | * implementation than the default implementation in Calendar. |
||
| 2052 | * |
||
| 2053 | * @author Dominik del Bondio <[email protected]> |
||
| 2054 | * @author The ICU Project |
||
| 2055 | * @since 0.11.0 |
||
| 2056 | */ |
||
| 2057 | protected function handleGetMonthLength($extendedYear, $month) |
||
| 2062 | |||
| 2063 | /** |
||
| 2064 | * Return the number of days in the given extended year of this |
||
| 2065 | * calendar system. Subclasses should override this method if they can |
||
| 2066 | * provide a more correct or more efficient implementation than the |
||
| 2067 | * default implementation in Calendar. |
||
| 2068 | * |
||
| 2069 | * @author Dominik del Bondio <[email protected]> |
||
| 2070 | * @author The ICU Project |
||
| 2071 | * @since 0.11.0 |
||
| 2072 | */ |
||
| 2073 | protected function handleGetYearLength($eyear) |
||
| 2078 | |||
| 2079 | /** |
||
| 2080 | * Return the extended year defined by the current fields. This will |
||
| 2081 | * use the EXTENDED_YEAR field or the YEAR and supra-year fields |
||
| 2082 | * (such as ERA) specific to the calendar system, depending on which set |
||
| 2083 | * of fields is newer. |
||
| 2084 | * |
||
| 2085 | * @return int the extended year |
||
| 2086 | * |
||
| 2087 | * @author Dominik del Bondio <[email protected]> |
||
| 2088 | * @author The ICU Project |
||
| 2089 | * @since 0.11.0 |
||
| 2090 | */ |
||
| 2091 | abstract protected function handleGetExtendedYear(); |
||
| 2092 | |||
| 2093 | /** |
||
| 2094 | * Subclasses may override this. This method calls |
||
| 2095 | * handleGetMonthLength() to obtain the calendar-specific month |
||
| 2096 | * length. |
||
| 2097 | * |
||
| 2098 | * @param string $bestField which field to use to calculate the date |
||
| 2099 | * |
||
| 2100 | * @return int julian day specified by calendar fields. |
||
| 2101 | * |
||
| 2102 | * @author Dominik del Bondio <[email protected]> |
||
| 2103 | * @author The ICU Project |
||
| 2104 | * @since 0.11.0 |
||
| 2105 | */ |
||
| 2106 | protected function handleComputeJulianDay($bestField) |
||
| 2270 | |||
| 2271 | /** |
||
| 2272 | * Subclasses must override this to convert from week fields |
||
| 2273 | * (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case |
||
| 2274 | * where YEAR, EXTENDED_YEAR are not set. |
||
| 2275 | * The Calendar implementation assumes yearWoy is in extended gregorian form |
||
| 2276 | * |
||
| 2277 | * @internal |
||
| 2278 | * |
||
| 2279 | * @param int $yearWoy |
||
| 2280 | * @param int $woy |
||
| 2281 | * |
||
| 2282 | * @return int the extended year, UCAL_EXTENDED_YEAR |
||
| 2283 | * |
||
| 2284 | * @author Dominik del Bondio <[email protected]> |
||
| 2285 | * @author The ICU Project |
||
| 2286 | * @since 0.11.0 |
||
| 2287 | */ |
||
| 2288 | protected function handleGetExtendedYearFromWeekFields($yearWoy, $woy) |
||
| 2401 | |||
| 2402 | /** |
||
| 2403 | * Compute the Julian day from fields. Will determine whether to use |
||
| 2404 | * the JULIAN_DAY field directly, or other fields. |
||
| 2405 | * |
||
| 2406 | * @return int the julian day |
||
| 2407 | * |
||
| 2408 | * @author Dominik del Bondio <[email protected]> |
||
| 2409 | * @author The ICU Project |
||
| 2410 | * @since 0.11.0 |
||
| 2411 | */ |
||
| 2412 | protected function computeJulianDay() |
||
| 2437 | |||
| 2438 | /** |
||
| 2439 | * Compute the milliseconds in the day from the fields. This is a |
||
| 2440 | * value from 0 to 23:59:59.999 inclusive, unless fields are out of |
||
| 2441 | * range, in which case it can be an arbitrary value. This value |
||
| 2442 | * reflects local zone wall time. |
||
| 2443 | * |
||
| 2444 | * @return int The milliseconds in the day |
||
| 2445 | * |
||
| 2446 | * @author Dominik del Bondio <[email protected]> |
||
| 2447 | * @author The ICU Project |
||
| 2448 | * @since 0.11.0 |
||
| 2449 | */ |
||
| 2450 | protected function computeMillisInDay() |
||
| 2488 | |||
| 2489 | /** |
||
| 2490 | * This method can assume EXTENDED_YEAR has been set. |
||
| 2491 | * |
||
| 2492 | * @param double $millis milliseconds of the date fields |
||
| 2493 | * @param int $millisInDay milliseconds of the time fields; may be out or range. |
||
| 2494 | * |
||
| 2495 | * @return int |
||
| 2496 | * |
||
| 2497 | * @author Dominik del Bondio <[email protected]> |
||
| 2498 | * @author The ICU Project |
||
| 2499 | * @since 0.11.0 |
||
| 2500 | */ |
||
| 2501 | protected function computeZoneOffset($millis, $millisInDay) |
||
| 2511 | |||
| 2512 | /** |
||
| 2513 | * Determine the best stamp in a range. |
||
| 2514 | * |
||
| 2515 | * @param int $first first enum to look at |
||
| 2516 | * @param int $last last enum to look at |
||
| 2517 | * @param int $bestStampSoFar stamp prior to function call |
||
| 2518 | * |
||
| 2519 | * @return int the stamp value of the best stamp |
||
| 2520 | * |
||
| 2521 | * @author Dominik del Bondio <[email protected]> |
||
| 2522 | * @author The ICU Project |
||
| 2523 | * @since 0.11.0 |
||
| 2524 | */ |
||
| 2525 | protected function newestStamp($first, $last, $bestStampSoFar) |
||
| 2535 | |||
| 2536 | /** |
||
| 2537 | * @var array Precedence table for Dates |
||
| 2538 | * @see #resolveFields |
||
| 2539 | * @internal |
||
| 2540 | * |
||
| 2541 | * @author Dominik del Bondio <[email protected]> |
||
| 2542 | * @author The ICU Project |
||
| 2543 | * @since 0.11.0 |
||
| 2544 | */ |
||
| 2545 | static $kDatePrecedence = array( |
||
| 2546 | array( |
||
| 2547 | array(DateDefinitions::DAY_OF_MONTH, self::RESOLVE_STOP), |
||
| 2548 | array(DateDefinitions::WEEK_OF_YEAR, DateDefinitions::DAY_OF_WEEK, self::RESOLVE_STOP), |
||
| 2549 | array(DateDefinitions::WEEK_OF_MONTH, DateDefinitions::DAY_OF_WEEK, self::RESOLVE_STOP), |
||
| 2550 | array(DateDefinitions::DAY_OF_WEEK_IN_MONTH, DateDefinitions::DAY_OF_WEEK, self::RESOLVE_STOP), |
||
| 2551 | array(DateDefinitions::WEEK_OF_YEAR, DateDefinitions::DOW_LOCAL, self::RESOLVE_STOP), |
||
| 2552 | array(DateDefinitions::WEEK_OF_MONTH, DateDefinitions::DOW_LOCAL, self::RESOLVE_STOP), |
||
| 2553 | array(DateDefinitions::DAY_OF_WEEK_IN_MONTH, DateDefinitions::DOW_LOCAL, self::RESOLVE_STOP), |
||
| 2554 | array(DateDefinitions::DAY_OF_YEAR, self::RESOLVE_STOP), |
||
| 2555 | // kResolveRemap | UCAL_DAY_OF_MONTH |
||
| 2556 | array(37, DateDefinitions::YEAR, self::RESOLVE_STOP), // if YEAR is set over YEAR_WOY use DAY_OF_MONTH |
||
| 2557 | // kResolveRemap | UCAL_WEEK_OF_YEAR |
||
| 2558 | array(35, DateDefinitions::YEAR_WOY, self::RESOLVE_STOP), // if YEAR_WOY is set, calc based on WEEK_OF_YEAR |
||
| 2559 | array(self::RESOLVE_STOP), |
||
| 2560 | ), |
||
| 2561 | array( |
||
| 2562 | array(DateDefinitions::WEEK_OF_YEAR, self::RESOLVE_STOP), |
||
| 2563 | array(DateDefinitions::WEEK_OF_MONTH, self::RESOLVE_STOP), |
||
| 2564 | array(DateDefinitions::DAY_OF_WEEK_IN_MONTH, self::RESOLVE_STOP), |
||
| 2565 | // kResolveRemap | UCAL_DAY_OF_WEEK_IN_MONTH |
||
| 2566 | array(40, DateDefinitions::DAY_OF_WEEK, self::RESOLVE_STOP), |
||
| 2567 | // self::kResolveRemap | UCAL_DAY_OF_WEEK_IN_MONTH |
||
| 2568 | array(40, DateDefinitions::DOW_LOCAL, self::RESOLVE_STOP), |
||
| 2569 | array(self::RESOLVE_STOP), |
||
| 2570 | ), |
||
| 2571 | array( |
||
| 2572 | array(self::RESOLVE_STOP), |
||
| 2573 | ), |
||
| 2574 | ); |
||
| 2575 | |||
| 2576 | /** |
||
| 2577 | * @var array Precedence table for Year |
||
| 2578 | * @see #resolveFields |
||
| 2579 | * @internal |
||
| 2580 | * |
||
| 2581 | * @author Dominik del Bondio <[email protected]> |
||
| 2582 | * @author The ICU Project |
||
| 2583 | * @since 0.11.0 |
||
| 2584 | */ |
||
| 2585 | protected static $kYearPrecedence = array( |
||
| 2586 | array( |
||
| 2587 | array(DateDefinitions::YEAR, self::RESOLVE_STOP), |
||
| 2588 | array(DateDefinitions::EXTENDED_YEAR, self::RESOLVE_STOP), |
||
| 2589 | array(DateDefinitions::YEAR_WOY, DateDefinitions::WEEK_OF_YEAR, self::RESOLVE_STOP), // YEAR_WOY is useless without WEEK_OF_YEAR |
||
| 2590 | array(self::RESOLVE_STOP), |
||
| 2591 | ), |
||
| 2592 | array( |
||
| 2593 | array(self::RESOLVE_STOP), |
||
| 2594 | ), |
||
| 2595 | ); |
||
| 2596 | |||
| 2597 | /** |
||
| 2598 | * @var array Precedence table for Day of Week |
||
| 2599 | * @see #resolveFields |
||
| 2600 | * @internal |
||
| 2601 | * |
||
| 2602 | * @author Dominik del Bondio <[email protected]> |
||
| 2603 | * @author The ICU Project |
||
| 2604 | * @since 0.11.0 |
||
| 2605 | */ |
||
| 2606 | protected static $kDOWPrecedence = array( |
||
| 2607 | array( |
||
| 2608 | array(DateDefinitions::DAY_OF_WEEK, self::RESOLVE_STOP, self::RESOLVE_STOP), |
||
| 2609 | array(DateDefinitions::DOW_LOCAL, self::RESOLVE_STOP, self::RESOLVE_STOP), |
||
| 2610 | array(self::RESOLVE_STOP), |
||
| 2611 | ), |
||
| 2612 | array( |
||
| 2613 | array(self::RESOLVE_STOP), |
||
| 2614 | ), |
||
| 2615 | ); |
||
| 2616 | |||
| 2617 | /** |
||
| 2618 | * Given a precedence table, return the newest field combination in |
||
| 2619 | * the table, or UCAL_FIELD_COUNT if none is found. |
||
| 2620 | * |
||
| 2621 | * <p>The precedence table is a 3-dimensional array of integers. It |
||
| 2622 | * may be thought of as an array of groups. Each group is an array of |
||
| 2623 | * lines. Each line is an array of field numbers. Within a line, if |
||
| 2624 | * all fields are set, then the time stamp of the line is taken to be |
||
| 2625 | * the stamp of the most recently set field. If any field of a line is |
||
| 2626 | * unset, then the line fails to match. Within a group, the line with |
||
| 2627 | * the newest time stamp is selected. The first field of the line is |
||
| 2628 | * returned to indicate which line matched. |
||
| 2629 | * |
||
| 2630 | * <p>In some cases, it may be desirable to map a line to field that |
||
| 2631 | * whose stamp is NOT examined. For example, if the best field is |
||
| 2632 | * DAY_OF_WEEK then the DAY_OF_WEEK_IN_MONTH algorithm may be used. In |
||
| 2633 | * order to do this, insert the value <code>kResolveRemap | F</code> at |
||
| 2634 | * the start of the line, where <code>F</code> is the desired return |
||
| 2635 | * field value. This field will NOT be examined; it only determines |
||
| 2636 | * the return value if the other fields in the line are the newest. |
||
| 2637 | * |
||
| 2638 | * <p>If all lines of a group contain at least one unset field, then no |
||
| 2639 | * line will match, and the group as a whole will fail to match. In |
||
| 2640 | * that case, the next group will be processed. If all groups fail to |
||
| 2641 | * match, then UCAL_FIELD_COUNT is returned. |
||
| 2642 | * @internal |
||
| 2643 | * |
||
| 2644 | * @param array $precedenceTable the precedence table |
||
| 2645 | * |
||
| 2646 | * @return int the best field |
||
| 2647 | * |
||
| 2648 | * @author Dominik del Bondio <[email protected]> |
||
| 2649 | * @author The ICU Project |
||
| 2650 | * @since 0.11.0 |
||
| 2651 | */ |
||
| 2652 | protected function resolveFields($precedenceTable) |
||
| 2681 | |||
| 2682 | /** |
||
| 2683 | * @return array |
||
| 2684 | * |
||
| 2685 | * @author Dominik del Bondio <[email protected]> |
||
| 2686 | * @author The ICU Project |
||
| 2687 | * @since 0.11.0 |
||
| 2688 | */ |
||
| 2689 | protected function getFieldResolutionTable() |
||
| 2693 | |||
| 2694 | /** |
||
| 2695 | * Return the field that is newer, either defaultField, or alternateField. |
||
| 2696 | * If neither is newer or neither is set, return defaultField. |
||
| 2697 | * @internal |
||
| 2698 | * |
||
| 2699 | * @param int |
||
| 2700 | * @param int |
||
| 2701 | * |
||
| 2702 | * @return int |
||
| 2703 | * |
||
| 2704 | * @author Dominik del Bondio <[email protected]> |
||
| 2705 | * @author The ICU Project |
||
| 2706 | * @since 0.11.0 |
||
| 2707 | */ |
||
| 2708 | protected function newerField($defaultField, $alternateField) |
||
| 2715 | |||
| 2716 | /** |
||
| 2717 | * Helper function for calculating limits by trial and error |
||
| 2718 | * |
||
| 2719 | * @param int $field The field being investigated |
||
| 2720 | * @param int $startValue starting (least max) value of field |
||
| 2721 | * @param int $endValue ending (greatest max) value of field |
||
| 2722 | * |
||
| 2723 | * @return int |
||
| 2724 | * |
||
| 2725 | * @author Dominik del Bondio <[email protected]> |
||
| 2726 | * @author The ICU Project |
||
| 2727 | * @since 0.11.0 |
||
| 2728 | */ |
||
| 2729 | protected function getActualHelper($field, $startValue, $endValue) |
||
| 2760 | |||
| 2761 | /** |
||
| 2762 | * @var bool The flag which indicates if the current time is set in the |
||
| 2763 | * calendar. |
||
| 2764 | */ |
||
| 2765 | protected $fIsTimeSet = false; |
||
| 2766 | |||
| 2767 | /** |
||
| 2768 | * @var bool True if the fields are in sync with the currently set time |
||
| 2769 | * of this Calendar. If false, then the next attempt to get |
||
| 2770 | * the value of a field will force a recomputation of all |
||
| 2771 | * fields from the current value of the time field. |
||
| 2772 | */ |
||
| 2773 | protected $fAreFieldsInSync = false; |
||
| 2774 | |||
| 2775 | /** |
||
| 2776 | * @var bool True if all of the fields have been set. This is |
||
| 2777 | * initially false, and set to true by computeFields(). |
||
| 2778 | */ |
||
| 2779 | protected $fAreAllFieldsSet = false; |
||
| 2780 | |||
| 2781 | /** |
||
| 2782 | * @var bool True if all fields have been virtually set, but have not |
||
| 2783 | * yet been computed. This occurs only in setTimeInMillis(). |
||
| 2784 | * A calendar set to this state will compute all fields from |
||
| 2785 | * the time if it becomes necessary, but otherwise will delay |
||
| 2786 | * such computation. |
||
| 2787 | */ |
||
| 2788 | protected $fAreFieldsVirtuallySet = false; |
||
| 2789 | |||
| 2790 | /** |
||
| 2791 | * Get the current time without recomputing. |
||
| 2792 | * |
||
| 2793 | * @return float the current time without recomputing. |
||
| 2794 | * |
||
| 2795 | * @author Dominik del Bondio <[email protected]> |
||
| 2796 | * @author The ICU Project |
||
| 2797 | * @since 0.11.0 |
||
| 2798 | */ |
||
| 2799 | protected function internalGetTime() |
||
| 2803 | |||
| 2804 | /** |
||
| 2805 | * Set the current time without affecting flags or fields. |
||
| 2806 | * |
||
| 2807 | * @param float $time The time to be set |
||
| 2808 | * |
||
| 2809 | * @author Dominik del Bondio <[email protected]> |
||
| 2810 | * @author The ICU Project |
||
| 2811 | * @since 0.11.0 |
||
| 2812 | */ |
||
| 2813 | protected function internalSetTime($time) |
||
| 2817 | |||
| 2818 | /** |
||
| 2819 | * @var array The time fields containing values into which the millis |
||
| 2820 | * is computed. |
||
| 2821 | */ |
||
| 2822 | protected $fFields; |
||
| 2823 | |||
| 2824 | /** |
||
| 2825 | * @var array The flags which tell if a specified time field for the |
||
| 2826 | * calendar is set. |
||
| 2827 | * |
||
| 2828 | * @author Dominik del Bondio <[email protected]> |
||
| 2829 | * @author The ICU Project |
||
| 2830 | * @since 0.11.0 |
||
| 2831 | * |
||
| 2832 | * @deprecated ICU 2.8 use (fStamp[n]!=kUnset) |
||
| 2833 | */ |
||
| 2834 | protected $fIsSet; |
||
| 2835 | |||
| 2836 | /** Special values of stamp[] |
||
| 2837 | * |
||
| 2838 | * @author Dominik del Bondio <[email protected]> |
||
| 2839 | * @author The ICU Project |
||
| 2840 | * @since 0.11.0 |
||
| 2841 | */ |
||
| 2842 | const kUnset = 0; |
||
| 2843 | const kInternallySet = 1; |
||
| 2844 | const kMinimumUserStamp = 2; |
||
| 2845 | |||
| 2846 | /** |
||
| 2847 | * @var array Pseudo-time-stamps which specify when each field was set. |
||
| 2848 | * There are two special values, UNSET and INTERNALLY_SET. |
||
| 2849 | * Values from MINIMUM_USER_SET to Integer.MAX_VALUE are |
||
| 2850 | * legal user set values. |
||
| 2851 | */ |
||
| 2852 | protected $fStamp; |
||
| 2853 | |||
| 2854 | /** |
||
| 2855 | * Subclasses may override this method to compute several fields |
||
| 2856 | * specific to each calendar system. These are: |
||
| 2857 | * |
||
| 2858 | * <ul><li>DateDefinitions::ERA |
||
| 2859 | * <li>DateDefinitions::YEAR |
||
| 2860 | * <li>DateDefinitions::MONTH |
||
| 2861 | * <li>DateDefinitions::DAY_OF_MONTH |
||
| 2862 | * <li>DateDefinitions::DAY_OF_YEAR |
||
| 2863 | * <li>DateDefinitions::EXTENDED_YEAR</ul> |
||
| 2864 | * |
||
| 2865 | * Subclasses can refer to the DAY_OF_WEEK and DOW_LOCAL fields, which |
||
| 2866 | * will be set when this method is called. Subclasses can also call |
||
| 2867 | * the getGregorianXxx() methods to obtain Gregorian calendar |
||
| 2868 | * equivalents for the given Julian day. |
||
| 2869 | * |
||
| 2870 | * <p>In addition, subclasses should compute any subclass-specific |
||
| 2871 | * fields, that is, fields from BASE_FIELD_COUNT to |
||
| 2872 | * getFieldCount() - 1. |
||
| 2873 | * |
||
| 2874 | * <p>The default implementation in <code>Calendar</code> implements |
||
| 2875 | * a pure proleptic Gregorian calendar. |
||
| 2876 | * @internal |
||
| 2877 | * |
||
| 2878 | * @param int $julianDay The julian day |
||
| 2879 | * |
||
| 2880 | * @author Dominik del Bondio <[email protected]> |
||
| 2881 | * @author The ICU Project |
||
| 2882 | * @since 0.11.0 |
||
| 2883 | */ |
||
| 2884 | protected function handleComputeFields($julianDay) |
||
| 2899 | |||
| 2900 | /** |
||
| 2901 | * Return the extended year on the Gregorian calendar as computed by |
||
| 2902 | * <code>computeGregorianFields()</code>. |
||
| 2903 | * @see Calendar::computeGregorianFields |
||
| 2904 | * @internal |
||
| 2905 | * |
||
| 2906 | * @return int The gregorian year |
||
| 2907 | * |
||
| 2908 | * @author Dominik del Bondio <[email protected]> |
||
| 2909 | * @author The ICU Project |
||
| 2910 | * @since 0.11.0 |
||
| 2911 | */ |
||
| 2912 | protected function getGregorianYear() |
||
| 2916 | |||
| 2917 | /** |
||
| 2918 | * Return the month (0-based) on the Gregorian calendar as computed by |
||
| 2919 | * <code>computeGregorianFields()</code>. |
||
| 2920 | * @see Calendar::computeGregorianFields |
||
| 2921 | * @internal |
||
| 2922 | * |
||
| 2923 | * @return int The gregorian month |
||
| 2924 | * |
||
| 2925 | * @author Dominik del Bondio <[email protected]> |
||
| 2926 | * @author The ICU Project |
||
| 2927 | * @since 0.11.0 |
||
| 2928 | */ |
||
| 2929 | protected function getGregorianMonth() |
||
| 2933 | |||
| 2934 | /** |
||
| 2935 | * Return the day of year (1-based) on the Gregorian calendar as |
||
| 2936 | * computed by <code>computeGregorianFields()</code>. |
||
| 2937 | * @see Calendar::computeGregorianFields |
||
| 2938 | * @internal |
||
| 2939 | * |
||
| 2940 | * @return int The gregorian day of year |
||
| 2941 | * |
||
| 2942 | * @author Dominik del Bondio <[email protected]> |
||
| 2943 | * @author The ICU Project |
||
| 2944 | * @since 0.11.0 |
||
| 2945 | */ |
||
| 2946 | protected function getGregorianDayOfYear() |
||
| 2950 | |||
| 2951 | /** |
||
| 2952 | * Return the day of month (1-based) on the Gregorian calendar as |
||
| 2953 | * computed by <code>computeGregorianFields()</code>. |
||
| 2954 | * @see Calendar::computeGregorianFields |
||
| 2955 | * @internal |
||
| 2956 | * |
||
| 2957 | * @return int The gregorian day of month |
||
| 2958 | * |
||
| 2959 | * @author Dominik del Bondio <[email protected]> |
||
| 2960 | * @author The ICU Project |
||
| 2961 | * @since 0.11.0 |
||
| 2962 | */ |
||
| 2963 | protected function getGregorianDayOfMonth() |
||
| 2967 | |||
| 2968 | /** |
||
| 2969 | * Called by computeJulianDay. Returns the default month (0-based) for the |
||
| 2970 | * year, taking year and era into account. Defaults to 0 for Gregorian, which |
||
| 2971 | * doesn't care. |
||
| 2972 | * |
||
| 2973 | * @return int The default month for the year. |
||
| 2974 | * |
||
| 2975 | * @author Dominik del Bondio <[email protected]> |
||
| 2976 | * @author The ICU Project |
||
| 2977 | * @since 0.11.0 |
||
| 2978 | */ |
||
| 2979 | protected function getDefaultMonthInYear() |
||
| 2983 | |||
| 2984 | /** |
||
| 2985 | * Called by computeJulianDay. Returns the default day (1-based) for the |
||
| 2986 | * month, taking currently-set year and era into account. Defaults to 1 for |
||
| 2987 | * Gregorian. |
||
| 2988 | * |
||
| 2989 | * @param int $month The months |
||
| 2990 | * |
||
| 2991 | * @return int The default day for the month |
||
| 2992 | * |
||
| 2993 | * @author Dominik del Bondio <[email protected]> |
||
| 2994 | * @author The ICU Project |
||
| 2995 | * @since 0.11.0 |
||
| 2996 | */ |
||
| 2997 | protected function getDefaultDayInMonth($month) |
||
| 3001 | |||
| 3002 | //------------------------------------------------------------------------- |
||
| 3003 | // Protected utility methods for use by subclasses. These are very handy |
||
| 3004 | // for implementing add, roll, and computeFields. |
||
| 3005 | //------------------------------------------------------------------------- |
||
| 3006 | |||
| 3007 | /** |
||
| 3008 | * Adjust the specified field so that it is within |
||
| 3009 | * the allowable range for the date to which this calendar is set. |
||
| 3010 | * For example, in a Gregorian calendar pinning the |
||
| 3011 | * DateDefinitions::DAY_OF_MONTH field for a calendar set to April 31 |
||
| 3012 | * would cause it to be set to April 30. |
||
| 3013 | * <p> |
||
| 3014 | * <b>Subclassing:</b> |
||
| 3015 | * <br> |
||
| 3016 | * This utility method is intended for use by subclasses that need to |
||
| 3017 | * implement their own overrides of {@link #roll roll} and {@link #add add}. |
||
| 3018 | * <p> |
||
| 3019 | * <b>Note:</b> |
||
| 3020 | * <code>pinField</code> is implemented in terms of |
||
| 3021 | * {@link #getActualMinimum getActualMinimum} |
||
| 3022 | * and {@link #getActualMaximum getActualMaximum}. If either of those methods |
||
| 3023 | * uses a slow, iterative algorithm for a particular field, it would be |
||
| 3024 | * unwise to attempt to call <code>pinField</code> for that field. If you |
||
| 3025 | * really do need to do so, you should override this method to do |
||
| 3026 | * something more efficient for that field. |
||
| 3027 | * <p> |
||
| 3028 | * |
||
| 3029 | * @param string $field The calendar field whose value should be pinned. |
||
| 3030 | * |
||
| 3031 | * @see getActualMinimum |
||
| 3032 | * @see getActualMaximum |
||
| 3033 | * |
||
| 3034 | * @author Dominik del Bondio <[email protected]> |
||
| 3035 | * @author The ICU Project |
||
| 3036 | * @since 0.11.0 |
||
| 3037 | */ |
||
| 3038 | protected function pinField($field) |
||
| 3049 | |||
| 3050 | /** |
||
| 3051 | * Return the week number of a day, within a period. This may be the week |
||
| 3052 | * number in a year or the week number in a month. Usually this will be a |
||
| 3053 | * value >= 1, but if some initial days of the period are excluded from |
||
| 3054 | * week 1, because getMinimalDaysInFirstWeek is > 1, then the week number will |
||
| 3055 | * be zero for those initial days. This method requires the day number and day |
||
| 3056 | * of week for some known date in the period in order to determine the day of |
||
| 3057 | * week on the desired day. |
||
| 3058 | * <p> |
||
| 3059 | * <b>Subclassing:</b> |
||
| 3060 | * <br> |
||
| 3061 | * This method is intended for use by subclasses in implementing their |
||
| 3062 | * {@link #computeTime computeTime} and/or {@link #computeFields computeFields} methods. |
||
| 3063 | * It is often useful in {@link #getActualMinimum getActualMinimum} and |
||
| 3064 | * {@link #getActualMaximum getActualMaximum} as well. |
||
| 3065 | * <p> |
||
| 3066 | * This variant is handy for computing the week number of some other |
||
| 3067 | * day of a period (often the first or last day of the period) when its day |
||
| 3068 | * of the week is not known but the day number and day of week for some other |
||
| 3069 | * day in the period (e.g. the current date) <em>is</em> known. |
||
| 3070 | * <p> |
||
| 3071 | * |
||
| 3072 | * @param int $desiredDay The {@link #UCalendarDateFields DAY_OF_YEAR} or |
||
| 3073 | * {@link #UCalendarDateFields DAY_OF_MONTH} whose week |
||
| 3074 | * number is desired. |
||
| 3075 | * Should be 1 for the first day of the period. |
||
| 3076 | * |
||
| 3077 | * @param int $dayOfPeriod The {@link #UCalendarDateFields DAY_OF_YEAR} |
||
| 3078 | * or {@link #UCalendarDateFields DAY_OF_MONTH} for a day in |
||
| 3079 | * the period whose {@link #UCalendarDateFields DAY_OF_WEEK} |
||
| 3080 | * is specified by the <code>knownDayOfWeek</code> parameter. |
||
| 3081 | * Should be 1 for first day of period. |
||
| 3082 | * |
||
| 3083 | * @param int $dayOfWeek The {@link #UCalendarDateFields DAY_OF_WEEK} for the day |
||
| 3084 | * corresponding to the <code>knownDayOfPeriod</code> |
||
| 3085 | * parameter. |
||
| 3086 | * 1-based with 1=Sunday. |
||
| 3087 | * |
||
| 3088 | * @return int The week number (one-based), or zero if the day falls |
||
| 3089 | * before the first week because |
||
| 3090 | * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek} |
||
| 3091 | * is more than one. |
||
| 3092 | * |
||
| 3093 | * @author Dominik del Bondio <[email protected]> |
||
| 3094 | * @author The ICU Project |
||
| 3095 | * @since 0.11.0 |
||
| 3096 | */ |
||
| 3097 | protected function weekNumber1($desiredDay, $dayOfPeriod, $dayOfWeek) |
||
| 3121 | |||
| 3122 | /** |
||
| 3123 | * Return the week number of a day, within a period. This may be the week number in |
||
| 3124 | * a year, or the week number in a month. Usually this will be a value >= 1, but if |
||
| 3125 | * some initial days of the period are excluded from week 1, because |
||
| 3126 | * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek} is > 1, |
||
| 3127 | * then the week number will be zero for those |
||
| 3128 | * initial days. This method requires the day of week for the given date in order to |
||
| 3129 | * determine the result. |
||
| 3130 | * <p> |
||
| 3131 | * <b>Subclassing:</b> |
||
| 3132 | * <br> |
||
| 3133 | * This method is intended for use by subclasses in implementing their |
||
| 3134 | * {@link #computeTime computeTime} and/or {@link #computeFields computeFields} methods. |
||
| 3135 | * It is often useful in {@link #getActualMinimum getActualMinimum} and |
||
| 3136 | * {@link #getActualMaximum getActualMaximum} as well. |
||
| 3137 | * <p> |
||
| 3138 | * @param int $dayOfPeriod The {@link #UCalendarDateFields DAY_OF_YEAR} or |
||
| 3139 | * {@link #UCalendarDateFields DAY_OF_MONTH} whose week |
||
| 3140 | * number is desired. Should be 1 for the first day of the |
||
| 3141 | * period. |
||
| 3142 | * |
||
| 3143 | * @param int $dayOfWeek The {@link #UCalendarDateFields DAY_OF_WEEK} for the day |
||
| 3144 | * corresponding to the <code>dayOfPeriod</code> parameter. |
||
| 3145 | * 1-based with 1=Sunday. |
||
| 3146 | * |
||
| 3147 | * @return int The week number (one-based), or zero if the day falls |
||
| 3148 | * before the first week because |
||
| 3149 | * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek} |
||
| 3150 | * is more than one. |
||
| 3151 | * @internal |
||
| 3152 | * |
||
| 3153 | * @author Dominik del Bondio <[email protected]> |
||
| 3154 | * @author The ICU Project |
||
| 3155 | * @since 0.11.0 |
||
| 3156 | */ |
||
| 3157 | protected function weekNumber($dayOfPeriod, $dayOfWeek) |
||
| 3161 | |||
| 3162 | /** |
||
| 3163 | * returns the local DOW, valid range 0..6 |
||
| 3164 | * @internal |
||
| 3165 | * |
||
| 3166 | * @return int |
||
| 3167 | * |
||
| 3168 | * @author Dominik del Bondio <[email protected]> |
||
| 3169 | * @author The ICU Project |
||
| 3170 | * @since 0.11.0 |
||
| 3171 | */ |
||
| 3172 | protected function getLocalDOW() |
||
| 3193 | |||
| 3194 | /** |
||
| 3195 | * @var int The next available value for fStamp[] |
||
| 3196 | */ |
||
| 3197 | private $fNextStamp = 1;// = MINIMUM_USER_STAMP; |
||
| 3198 | |||
| 3199 | /** |
||
| 3200 | * @var float The current time set for the calendar. |
||
| 3201 | */ |
||
| 3202 | private $fTime; |
||
| 3203 | |||
| 3204 | /** |
||
| 3205 | * @see #setLenient |
||
| 3206 | * @var bool |
||
| 3207 | */ |
||
| 3208 | private $fLenient; |
||
| 3209 | |||
| 3210 | /** |
||
| 3211 | * @var TimeZone Time zone affects the time calculation done by |
||
| 3212 | * Calendar. Calendar subclasses use the time zone |
||
| 3213 | * data to produce the local time. |
||
| 3214 | */ |
||
| 3215 | private $fZone; |
||
| 3216 | |||
| 3217 | /** |
||
| 3218 | * Both firstDayOfWeek and minimalDaysInFirstWeek are locale-dependent. They are |
||
| 3219 | * used to figure out the week count for a specific date for a given locale. These |
||
| 3220 | * must be set when a Calendar is constructed. For example, in US locale, |
||
| 3221 | * firstDayOfWeek is SUNDAY; minimalDaysInFirstWeek is 1. They are used to figure |
||
| 3222 | * out the week count for a specific date for a given locale. These must be set when |
||
| 3223 | * a Calendar is constructed. |
||
| 3224 | * |
||
| 3225 | * @author Dominik del Bondio <[email protected]> |
||
| 3226 | * @author The ICU Project |
||
| 3227 | * @since 0.11.0 |
||
| 3228 | */ |
||
| 3229 | private $fFirstDayOfWeek; |
||
| 3230 | private $fMinimalDaysInFirstWeek; |
||
| 3231 | |||
| 3232 | /** |
||
| 3233 | * Sets firstDayOfWeek and minimalDaysInFirstWeek. Called at Calendar construction |
||
| 3234 | * time. |
||
| 3235 | * |
||
| 3236 | * @param Locale $desiredLocale The given locale. |
||
| 3237 | * @param string $type The calendar type identifier, e.g: gregorian, |
||
| 3238 | * buddhist, etc. |
||
| 3239 | * |
||
| 3240 | * @author Dominik del Bondio <[email protected]> |
||
| 3241 | * @author The ICU Project |
||
| 3242 | * @since 0.11.0 |
||
| 3243 | */ |
||
| 3244 | private function setWeekCountData(Locale $desiredLocale, $type) |
||
| 3267 | |||
| 3268 | /** |
||
| 3269 | * Recompute the time and update the status fields isTimeSet |
||
| 3270 | * and areFieldsSet. Callers should check isTimeSet and only |
||
| 3271 | * call this method if isTimeSet is false. |
||
| 3272 | * |
||
| 3273 | * @author Dominik del Bondio <[email protected]> |
||
| 3274 | * @author The ICU Project |
||
| 3275 | * @since 0.11.0 |
||
| 3276 | */ |
||
| 3277 | private function updateTime() |
||
| 3291 | |||
| 3292 | /** |
||
| 3293 | * @var int The Gregorian year, as computed by computeGregorianFields() |
||
| 3294 | * and returned by getGregorianYear(). |
||
| 3295 | * @see Calendar::computeGregorianFields |
||
| 3296 | */ |
||
| 3297 | private $fGregorianYear; |
||
| 3298 | |||
| 3299 | /** |
||
| 3300 | * @var int The Gregorian month, as computed by |
||
| 3301 | * computeGregorianFields() and returned by |
||
| 3302 | * getGregorianMonth(). |
||
| 3303 | * @see Calendar::computeGregorianFields |
||
| 3304 | */ |
||
| 3305 | private $fGregorianMonth; |
||
| 3306 | |||
| 3307 | /** |
||
| 3308 | * @var int The Gregorian day of the year, as computed by |
||
| 3309 | * computeGregorianFields() and returned by |
||
| 3310 | * getGregorianDayOfYear(). |
||
| 3311 | * @see Calendar::computeGregorianFields |
||
| 3312 | */ |
||
| 3313 | private $fGregorianDayOfYear; |
||
| 3314 | |||
| 3315 | /** |
||
| 3316 | * @var int The Gregorian day of the month, as computed by |
||
| 3317 | * computeGregorianFields() and returned by |
||
| 3318 | * getGregorianDayOfMonth(). |
||
| 3319 | * @see Calendar::computeGregorianFields |
||
| 3320 | */ |
||
| 3321 | private $fGregorianDayOfMonth; |
||
| 3322 | |||
| 3323 | /* calculations */ |
||
| 3324 | |||
| 3325 | /** |
||
| 3326 | * Compute the Gregorian calendar year, month, and day of month from |
||
| 3327 | * the given Julian day. These values are not stored in fields, but in |
||
| 3328 | * member variables gregorianXxx. Also compute the DAY_OF_WEEK and |
||
| 3329 | * DOW_LOCAL fields. |
||
| 3330 | * |
||
| 3331 | * @param int $julianDay The julian day |
||
| 3332 | * |
||
| 3333 | * @author Dominik del Bondio <[email protected]> |
||
| 3334 | * @author The ICU Project |
||
| 3335 | * @since 0.11.0 |
||
| 3336 | */ |
||
| 3337 | private function computeGregorianAndDOWFields($julianDay) |
||
| 3353 | |||
| 3354 | /** |
||
| 3355 | * Compute the Gregorian calendar year, month, and day of month from the |
||
| 3356 | * Julian day. These values are not stored in fields, but in member |
||
| 3357 | * variables gregorianXxx. They are used for time zone computations and by |
||
| 3358 | * subclasses that are Gregorian derivatives. Subclasses may call this |
||
| 3359 | * method to perform a Gregorian calendar millis->fields computation. |
||
| 3360 | * To perform a Gregorian calendar fields->millis computation, call |
||
| 3361 | * computeGregorianMonthStart(). |
||
| 3362 | * @see #computeGregorianMonthStart |
||
| 3363 | * |
||
| 3364 | * @param int $julianDay The julian day |
||
| 3365 | * |
||
| 3366 | * @author Dominik del Bondio <[email protected]> |
||
| 3367 | * @author The ICU Project |
||
| 3368 | * @since 0.11.0 |
||
| 3369 | */ |
||
| 3370 | private function computeGregorianFields($julianDay) |
||
| 3375 | |||
| 3376 | /** |
||
| 3377 | * Compute the fields WEEK_OF_YEAR, YEAR_WOY, WEEK_OF_MONTH, |
||
| 3378 | * DAY_OF_WEEK_IN_MONTH, and DOW_LOCAL from EXTENDED_YEAR, YEAR, |
||
| 3379 | * DAY_OF_WEEK, and DAY_OF_YEAR. The latter fields are computed by the |
||
| 3380 | * subclass based on the calendar system. |
||
| 3381 | * |
||
| 3382 | * <p>The YEAR_WOY field is computed simplistically. It is equal to YEAR |
||
| 3383 | * most of the time, but at the year boundary it may be adjusted to YEAR-1 |
||
| 3384 | * or YEAR+1 to reflect the overlap of a week into an adjacent year. In |
||
| 3385 | * this case, a simple increment or decrement is performed on YEAR, even |
||
| 3386 | * though this may yield an invalid YEAR value. For instance, if the YEAR |
||
| 3387 | * is part of a calendar system with an N-year cycle field CYCLE, then |
||
| 3388 | * incrementing the YEAR may involve incrementing CYCLE and setting YEAR |
||
| 3389 | * back to 0 or 1. This is not handled by this code, and in fact cannot be |
||
| 3390 | * simply handled without having subclasses define an entire parallel set of |
||
| 3391 | * fields for fields larger than or equal to a year. This additional |
||
| 3392 | * complexity is not warranted, since the intention of the YEAR_WOY field is |
||
| 3393 | * to support ISO 8601 notation, so it will typically be used with a |
||
| 3394 | * proleptic Gregorian calendar, which has no field larger than a year. |
||
| 3395 | * |
||
| 3396 | * @author Dominik del Bondio <[email protected]> |
||
| 3397 | * @author The ICU Project |
||
| 3398 | * @since 0.11.0 |
||
| 3399 | */ |
||
| 3400 | private function computeWeekFields() |
||
| 3463 | |||
| 3464 | /** |
||
| 3465 | * Ensure that each field is within its valid range by calling {@link |
||
| 3466 | * #validateField(int, int&)} on each field that has been set. This method |
||
| 3467 | * should only be called if this calendar is not lenient. |
||
| 3468 | * @see #isLenient |
||
| 3469 | * @see #validateField(int, int&) |
||
| 3470 | * @internal |
||
| 3471 | * |
||
| 3472 | * @author Dominik del Bondio <[email protected]> |
||
| 3473 | * @author The ICU Project |
||
| 3474 | * @since 0.11.0 |
||
| 3475 | */ |
||
| 3476 | private function validateFields() |
||
| 3484 | |||
| 3485 | /** |
||
| 3486 | * Validate a single field of this calendar. Subclasses should |
||
| 3487 | * override this method to validate any calendar-specific fields. |
||
| 3488 | * Generic fields can be handled by |
||
| 3489 | * <code>Calendar.validateField()</code>. |
||
| 3490 | * @see #validateField(int, int, int, int&) |
||
| 3491 | * @internal |
||
| 3492 | * |
||
| 3493 | * @param int $field The field |
||
| 3494 | * |
||
| 3495 | * @author Dominik del Bondio <[email protected]> |
||
| 3496 | * @author The ICU Project |
||
| 3497 | * @since 0.11.0 |
||
| 3498 | */ |
||
| 3499 | private function validateField($field) |
||
| 3521 | |||
| 3522 | /** |
||
| 3523 | * Validate a single field of this calendar given its minimum and |
||
| 3524 | * maximum allowed value. If the field is out of range, |
||
| 3525 | * <code>InvalidArgumentException</code> will be thrown. Subclasses may |
||
| 3526 | * use this method in their implementation of {@link |
||
| 3527 | * #validateField(int, int&)}. |
||
| 3528 | * @internal |
||
| 3529 | * |
||
| 3530 | * @throws <b>InvalidArgumentException</b> |
||
| 3531 | * |
||
| 3532 | * @param string |
||
| 3533 | * @param int |
||
| 3534 | * @param int |
||
| 3535 | * |
||
| 3536 | * @author Dominik del Bondio <[email protected]> |
||
| 3537 | * @author The ICU Project |
||
| 3538 | * @since 0.11.0 |
||
| 3539 | */ |
||
| 3540 | private function validateField1($field, $min, $max) |
||
| 3547 | |||
| 3548 | /** |
||
| 3549 | * Convert a quasi Julian date to the day of the week. The Julian date used here is |
||
| 3550 | * not a true Julian date, since it is measured from midnight, not noon. Return |
||
| 3551 | * value is one-based. |
||
| 3552 | * |
||
| 3553 | * @param double $julian The given Julian date number. |
||
| 3554 | * |
||
| 3555 | * @return int Day number from 1..7 (SUN..SAT). |
||
| 3556 | * |
||
| 3557 | * @internal |
||
| 3558 | * |
||
| 3559 | * @author Dominik del Bondio <[email protected]> |
||
| 3560 | * @author The ICU Project |
||
| 3561 | * @since 0.11.0 |
||
| 3562 | */ |
||
| 3563 | protected function julianDayToDayOfWeek($julian) |
||
| 3573 | |||
| 3574 | /** |
||
| 3575 | * @var string |
||
| 3576 | */ |
||
| 3577 | private $validLocale; |
||
| 3578 | |||
| 3579 | /** |
||
| 3580 | * @var string |
||
| 3581 | */ |
||
| 3582 | private $actualLocale; |
||
| 3583 | |||
| 3584 | /** |
||
| 3585 | * @internal |
||
| 3586 | * @return bool if this calendar has a default century (i.e. 03 -> 2003) |
||
| 3587 | * |
||
| 3588 | * @author Dominik del Bondio <[email protected]> |
||
| 3589 | * @author The ICU Project |
||
| 3590 | * @since 0.11.0 |
||
| 3591 | */ |
||
| 3592 | abstract public function haveDefaultCentury(); |
||
| 3593 | |||
| 3594 | /** |
||
| 3595 | * @internal |
||
| 3596 | * @return float the start of the default century, as a UDate |
||
| 3597 | * |
||
| 3598 | * @author Dominik del Bondio <[email protected]> |
||
| 3599 | * @author The ICU Project |
||
| 3600 | * @since 0.11.0 |
||
| 3601 | */ |
||
| 3602 | abstract public function defaultCenturyStart(); |
||
| 3603 | |||
| 3604 | /** |
||
| 3605 | * @internal |
||
| 3606 | * @return int the beginning year of the default century, as a year |
||
| 3607 | * |
||
| 3608 | * @author Dominik del Bondio <[email protected]> |
||
| 3609 | * @author The ICU Project |
||
| 3610 | * @since 0.11.0 |
||
| 3611 | */ |
||
| 3612 | abstract public function defaultCenturyStartYear(); |
||
| 3613 | |||
| 3614 | /** |
||
| 3615 | * Returns the type of the implementing calendar. |
||
| 3616 | * |
||
| 3617 | * @return string The type of this calendar (Gregorian, ...) |
||
| 3618 | * |
||
| 3619 | * @author Dominik del Bondio <[email protected]> |
||
| 3620 | * @since 0.11.0 |
||
| 3621 | */ |
||
| 3622 | abstract public function getType(); |
||
| 3623 | } |
||
| 3624 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.