Exemplo n.º 1
0
 protected static function componentsInTimeZoneToTime($year, $month, $day, $hour, $minute, $second, $millisecond, $timeZone)
 {
     assert('self::areComponentsValid($year, $month, $day, $hour, $minute, $second, $millisecond)', vs(isset($this), get_defined_vars()));
     assert('1000 <= $year && $year <= 9999', vs(isset($this), get_defined_vars()));
     $strYear = CString::fromInt($year);
     $strMonth = CString::fromInt($month);
     $strDay = CString::fromInt($day);
     $strHour = CString::padStart(CString::fromInt($hour), "0", 2);
     $strMinute = CString::padStart(CString::fromInt($minute), "0", 2);
     $strSecond = CString::padStart(CString::fromInt($second), "0", 2);
     $dt = DateTime::createFromFormat("Y,m,d,H,i,s", "{$strYear},{$strMonth},{$strDay},{$strHour},{$strMinute},{$strSecond}", is_cstring($timeZone) ? new DateTimeZone($timeZone) : $timeZone->DTimeZone());
     if (!is_object($dt)) {
         assert('false', vs(isset($this), get_defined_vars()));
     }
     $UTime = $dt->getTimestamp();
     $MTime;
     if (!($UTime < 0 && $millisecond != 0)) {
         $MTime = $millisecond;
     } else {
         $UTime++;
         $MTime = $millisecond - 1000;
     }
     return new self($UTime, $MTime);
 }
Exemplo n.º 2
0
 /**
  * Returns a character by its code point specified in an escaped fashion.
  *
  * For instance, "\u0041" would return "A".
  *
  * @param  string $code The Unicode code point prefixed with "\u". The number of hexadecimal digits in the string
  * should be four.
  *
  * @return string The Unicode character with the code point specified.
  */
 public static function fromCharCodeEsc($code)
 {
     assert('is_cstring($code)', vs(isset($this), get_defined_vars()));
     assert('CRegex::find($code, "/^\\\\\\\\u((?i)[0-9A-F]{4}(?<!FFFE|FFFF))\\\\z/")', vs(isset($this), get_defined_vars()));
     return json_decode("\"\\u" . CString::padStart(CString::substr($code, 2), "0", 4) . "\"");
 }