public function setTimeout($timeout) { $s = Std::int($timeout); $ms = Std::int(($timeout - $s) * 1000000); $r = stream_set_timeout($this->__s, $s, $ms); sys_net_Socket::checkError($r, 0, "Unable to set timeout"); }
static function snapMonth($dt, $direction) { $month = null; $days = Std::int(($dt - 62135596800.0 - datetime__DateTime_DateTime_Impl_::yearStart($dt)) / 86400) + 1; $month = datetime_utils_DateTimeMonthUtils::getMonth($days, datetime__DateTime_DateTime_Impl_::isLeapYear($dt)); $isLeap = datetime__DateTime_DateTime_Impl_::isLeapYear($dt); switch ($direction) { case -1: return datetime__DateTime_DateTime_Impl_::yearStart($dt) + datetime_utils_DateTimeMonthUtils::toSeconds($month, $isLeap); break; case 1: return datetime__DateTime_DateTime_Impl_::yearStart($dt) + datetime_utils_DateTimeMonthUtils::toSeconds($month, $isLeap) + datetime_utils_DateTimeMonthUtils::days($month, $isLeap) * 86400; break; case 0: $previous = datetime__DateTime_DateTime_Impl_::yearStart($dt) + datetime_utils_DateTimeMonthUtils::toSeconds($month, $isLeap); $next = datetime__DateTime_DateTime_Impl_::yearStart($dt) + datetime_utils_DateTimeMonthUtils::toSeconds($month, $isLeap) + datetime_utils_DateTimeMonthUtils::days($month, $isLeap) * 86400; if ($next - ($dt - 62135596800.0) > $dt - 62135596800.0 - $previous) { return $previous; } else { return $next; } break; } }
public function parseRec() { while (true) { $c = null; $index = $this->pos++; $c = ord(substr($this->str, $index, 1)); unset($index); switch ($c) { case 32: case 13: case 10: case 9: break; case 123: $obj = _hx_anonymous(array()); $field = null; $comma = null; while (true) { $c1 = null; $index1 = $this->pos++; $c1 = ord(substr($this->str, $index1, 1)); unset($index1); switch ($c1) { case 32: case 13: case 10: case 9: break; case 125: if ($field !== null || $comma === false) { $this->invalidChar(); } return $obj; break; case 58: if ($field === null) { $this->invalidChar(); } $value = $this->parseRec(); $obj->{$field} = $value; $field = null; $comma = true; break; case 44: if ($comma) { $comma = false; } else { $this->invalidChar(); } break; case 34: if ($comma) { $this->invalidChar(); } $field = $this->parseString(); break; default: $this->invalidChar(); break; } unset($c1); } break; case 91: $arr = new _hx_array(array()); $comma1 = null; while (true) { $c2 = null; $index2 = $this->pos++; $c2 = ord(substr($this->str, $index2, 1)); unset($index2); switch ($c2) { case 32: case 13: case 10: case 9: break; case 93: if ($comma1 === false) { $this->invalidChar(); } return $arr; break; case 44: if ($comma1) { $comma1 = false; } else { $this->invalidChar(); } break; default: if ($comma1) { $this->invalidChar(); } $this->pos--; $arr->push($this->parseRec()); $comma1 = true; break; } unset($c2); } break; case 116: $save = $this->pos; if (haxe_format_JsonParser_0($this, $c, $save) !== 114 || haxe_format_JsonParser_1($this, $c, $save) !== 117 || haxe_format_JsonParser_2($this, $c, $save) !== 101) { $this->pos = $save; $this->invalidChar(); } return true; break; case 102: $save1 = $this->pos; if (haxe_format_JsonParser_3($this, $c, $save1) !== 97 || haxe_format_JsonParser_4($this, $c, $save1) !== 108 || haxe_format_JsonParser_5($this, $c, $save1) !== 115 || haxe_format_JsonParser_6($this, $c, $save1) !== 101) { $this->pos = $save1; $this->invalidChar(); } return false; break; case 110: $save2 = $this->pos; if (haxe_format_JsonParser_7($this, $c, $save2) !== 117 || haxe_format_JsonParser_8($this, $c, $save2) !== 108 || haxe_format_JsonParser_9($this, $c, $save2) !== 108) { $this->pos = $save2; $this->invalidChar(); } return null; break; case 34: return $this->parseString(); break; case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 45: $c3 = $c; $start = $this->pos - 1; $minus = $c3 === 45; $digit = !$minus; $zero = $c3 === 48; $point = false; $e = false; $pm = false; $end = false; while (true) { $index13 = $this->pos++; $c3 = ord(substr($this->str, $index13, 1)); unset($index13); switch ($c3) { case 48: if ($zero && !$point) { $this->invalidNumber($start); } if ($minus) { $minus = false; $zero = true; } $digit = true; break; case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: if ($zero && !$point) { $this->invalidNumber($start); } if ($minus) { $minus = false; } $digit = true; $zero = false; break; case 46: if ($minus || $point) { $this->invalidNumber($start); } $digit = false; $point = true; break; case 101: case 69: if ($minus || $zero || $e) { $this->invalidNumber($start); } $digit = false; $e = true; break; case 43: case 45: if (!$e || $pm) { $this->invalidNumber($start); } $digit = false; $pm = true; break; default: if (!$digit) { $this->invalidNumber($start); } $this->pos--; $end = true; break; } if ($end) { break; } } $f = Std::parseFloat(_hx_substr($this->str, $start, $this->pos - $start)); $i = Std::int($f); if (_hx_equal($i, $f)) { return $i; } else { return $f; } break; default: $this->invalidChar(); break; } unset($c); } }
static function toString($this1) { $Y = datetime__DateTime_DateTime_Impl_::getYear($this1); $M = null; $days = Std::int(($this1 - 62135596800.0 - datetime__DateTime_DateTime_Impl_::yearStart($this1)) / 86400) + 1; $M = datetime_utils_DateTimeMonthUtils::getMonth($days, datetime__DateTime_DateTime_Impl_::isLeapYear($this1)); $D = null; $days1 = Std::int(($this1 - 62135596800.0 - datetime__DateTime_DateTime_Impl_::yearStart($this1)) / 86400) + 1; $D = datetime_utils_DateTimeMonthUtils::getMonthDay($days1, datetime__DateTime_DateTime_Impl_::isLeapYear($this1)); $h = Std::int(($this1 - Math::ffloor($this1 / 86400) * 86400) / 3600); $m = Std::int(($this1 - Math::ffloor($this1 / 3600) * 3600) / 60); $s = Std::int($this1 - Math::ffloor($this1 / 60) * 60); return "" . _hx_string_rec($Y, "") . "-" . _hx_string_or_null(datetime__DateTime_DateTime_Impl__4($D, $M, $Y, $h, $m, $s, $this1)) . "-" . _hx_string_or_null(datetime__DateTime_DateTime_Impl__5($D, $M, $Y, $h, $m, $s, $this1)) . " " . _hx_string_or_null(datetime__DateTime_DateTime_Impl__6($D, $M, $Y, $h, $m, $s, $this1)) . ":" . _hx_string_or_null(datetime__DateTime_DateTime_Impl__7($D, $M, $Y, $h, $m, $s, $this1)) . ":" . _hx_string_or_null(datetime__DateTime_DateTime_Impl__8($D, $M, $Y, $h, $m, $s, $this1)); }
public function pickSizes($t) { $w = $t->get_width(); $h = $t->get_height(); $v = $t->getCellView(); $csv = new coopy_Csv(null); $sizes = new _hx_array(array()); $row = -1; $total = $w - 1; $_g = 0; while ($_g < $w) { $x = $_g++; $m = 0; $m2 = 0; $mmax = 0; $mmostmax = 0; $mmin = -1; $_g1 = 0; while ($_g1 < $h) { $y = $_g1++; $txt = $this->getText($x, $y, false); if ($txt === "@@" && $row === -1) { $row = $y; } $len = strlen($txt); if ($y === $row) { $mmin = $len; } $m += $len; $m2 += $len * $len; if ($len > $mmax) { $mmax = $len; } unset($y, $txt, $len); } unset($_g1); $mean = $m / $h; $stddev = Math::sqrt($m2 / $h - $mean * $mean); $most = Std::int($mean + $stddev * 2 + 0.5); $_g11 = 0; while ($_g11 < $h) { $y1 = $_g11++; $txt1 = $this->getText($x, $y1, false); $len1 = strlen($txt1); if ($len1 <= $most) { if ($len1 > $mmostmax) { $mmostmax = $len1; } } unset($y1, $txt1, $len1); } unset($_g11); $full = $mmax; $most = $mmostmax; if ($mmin !== -1) { if ($most < $mmin) { $most = $mmin; } } $sizes->push($most); $total += $most; unset($x, $stddev, $most, $mmostmax, $mmin, $mmax, $mean, $m2, $m, $full); } if ($total > 130) { return null; } return $sizes; }
public function getTotalWeeks() { return Std::int(($this->end - 62135596800.0 - ($this->begin - 62135596800.0)) / 604800); }
static function setCookie($key, $value, $expire = null, $domain = null, $path = null, $secure = null, $httpOnly = null) { $t = null; if ($expire === null) { $t = 0; } else { $t = Std::int($expire->getTime() / 1000.0); } if ($path === null) { $path = "/"; } if ($domain === null) { $domain = ""; } if ($secure === null) { $secure = false; } if ($httpOnly === null) { $httpOnly = false; } setcookie($key, $value, $t, $path, $domain, $secure, $httpOnly); }
static function strftime($dt, $format) { $prevPos = 0; $pos = _hx_index_of($format, "%", null); $str = ""; while ($pos >= 0) { $str .= _hx_string_or_null(_hx_substring($format, $prevPos, $pos)); $pos++; $_g = ord(substr($format, $pos, 1)); switch ($_g) { case 100: $s = null; $s = _hx_string_rec(datetime_utils_DateTimeUtils_5($_g, $dt, $format, $pos, $prevPos, $s, $str), "") . ""; if (strlen("0") === 0 || strlen($s) >= 2) { $str .= _hx_string_or_null($s); } else { $str .= _hx_string_or_null(str_pad($s, Math::ceil((2 - strlen($s)) / strlen("0")) * strlen("0") + strlen($s), "0", STR_PAD_LEFT)); } break; case 101: $s1 = null; $s1 = _hx_string_rec(datetime_utils_DateTimeUtils_6($_g, $dt, $format, $pos, $prevPos, $s1, $str), "") . ""; if (strlen(" ") === 0 || strlen($s1) >= 2) { $str .= _hx_string_or_null($s1); } else { $str .= _hx_string_or_null(str_pad($s1, Math::ceil((2 - strlen($s1)) / strlen(" ")) * strlen(" ") + strlen($s1), " ", STR_PAD_LEFT)); } break; case 106: $day = Std::int(($dt - 62135596800.0 - datetime__DateTime_DateTime_Impl_::yearStart($dt)) / 86400) + 1; $s2 = "" . _hx_string_rec($day, ""); if (strlen("0") === 0 || strlen($s2) >= 3) { $str .= _hx_string_or_null($s2); } else { $str .= _hx_string_or_null(str_pad($s2, Math::ceil((3 - strlen($s2)) / strlen("0")) * strlen("0") + strlen($s2), "0", STR_PAD_LEFT)); } break; case 117: $str .= _hx_string_rec(datetime__DateTime_DateTime_Impl_::getWeekDay($dt, true), "") . ""; break; case 119: $str .= _hx_string_rec(datetime__DateTime_DateTime_Impl_::getWeekDay($dt, null), "") . ""; break; case 109: $s3 = null; $s3 = _hx_string_rec(datetime_utils_DateTimeUtils_7($_g, $dt, $format, $pos, $prevPos, $s3, $str), "") . ""; if (strlen("0") === 0 || strlen($s3) >= 2) { $str .= _hx_string_or_null($s3); } else { $str .= _hx_string_or_null(str_pad($s3, Math::ceil((2 - strlen($s3)) / strlen("0")) * strlen("0") + strlen($s3), "0", STR_PAD_LEFT)); } break; case 67: $s4 = _hx_string_rec(Std::int(datetime__DateTime_DateTime_Impl_::getYear($dt) / 100), "") . ""; if (strlen("0") === 0 || strlen($s4) >= 2) { $str .= _hx_string_or_null($s4); } else { $str .= _hx_string_or_null(str_pad($s4, Math::ceil((2 - strlen($s4)) / strlen("0")) * strlen("0") + strlen($s4), "0", STR_PAD_LEFT)); } break; case 121: $s5 = _hx_substr(_hx_string_rec(datetime__DateTime_DateTime_Impl_::getYear($dt), "") . "", -2, null); if (strlen("0") === 0 || strlen($s5) >= 2) { $str .= _hx_string_or_null($s5); } else { $str .= _hx_string_or_null(str_pad($s5, Math::ceil((2 - strlen($s5)) / strlen("0")) * strlen("0") + strlen($s5), "0", STR_PAD_LEFT)); } break; case 89: $str .= _hx_string_rec(datetime__DateTime_DateTime_Impl_::getYear($dt), "") . ""; break; case 86: $s6 = _hx_string_rec(datetime__DateTime_DateTime_Impl_::getWeek($dt), "") . ""; if (strlen("0") === 0 || strlen($s6) >= 2) { $str .= _hx_string_or_null($s6); } else { $str .= _hx_string_or_null(str_pad($s6, Math::ceil((2 - strlen($s6)) / strlen("0")) * strlen("0") + strlen($s6), "0", STR_PAD_LEFT)); } break; case 72: $s7 = _hx_string_rec(Std::int(($dt - Math::ffloor($dt / 86400) * 86400) / 3600), "") . ""; if (strlen("0") === 0 || strlen($s7) >= 2) { $str .= _hx_string_or_null($s7); } else { $str .= _hx_string_or_null(str_pad($s7, Math::ceil((2 - strlen($s7)) / strlen("0")) * strlen("0") + strlen($s7), "0", STR_PAD_LEFT)); } break; case 107: $s8 = _hx_string_rec(Std::int(($dt - Math::ffloor($dt / 86400) * 86400) / 3600), "") . ""; if (strlen(" ") === 0 || strlen($s8) >= 2) { $str .= _hx_string_or_null($s8); } else { $str .= _hx_string_or_null(str_pad($s8, Math::ceil((2 - strlen($s8)) / strlen(" ")) * strlen(" ") + strlen($s8), " ", STR_PAD_LEFT)); } break; case 73: $s9 = _hx_string_rec(datetime__DateTime_DateTime_Impl_::getHour12($dt), "") . ""; if (strlen("0") === 0 || strlen($s9) >= 2) { $str .= _hx_string_or_null($s9); } else { $str .= _hx_string_or_null(str_pad($s9, Math::ceil((2 - strlen($s9)) / strlen("0")) * strlen("0") + strlen($s9), "0", STR_PAD_LEFT)); } break; case 108: $s10 = _hx_string_rec(datetime__DateTime_DateTime_Impl_::getHour12($dt), "") . ""; if (strlen(" ") === 0 || strlen($s10) >= 2) { $str .= _hx_string_or_null($s10); } else { $str .= _hx_string_or_null(str_pad($s10, Math::ceil((2 - strlen($s10)) / strlen(" ")) * strlen(" ") + strlen($s10), " ", STR_PAD_LEFT)); } break; case 77: $s11 = _hx_string_rec(Std::int(($dt - Math::ffloor($dt / 3600) * 3600) / 60), "") . ""; if (strlen("0") === 0 || strlen($s11) >= 2) { $str .= _hx_string_or_null($s11); } else { $str .= _hx_string_or_null(str_pad($s11, Math::ceil((2 - strlen($s11)) / strlen("0")) * strlen("0") + strlen($s11), "0", STR_PAD_LEFT)); } break; case 112: if (Std::int(($dt - Math::ffloor($dt / 86400) * 86400) / 3600) < 12) { $str .= "AM"; } else { $str .= "PM"; } break; case 80: if (Std::int(($dt - Math::ffloor($dt / 86400) * 86400) / 3600) < 12) { $str .= "am"; } else { $str .= "pm"; } break; case 114: $str .= _hx_string_or_null(datetime_utils_DateTimeUtils_8($_g, $dt, $format, $pos, $prevPos, $str)) . _hx_string_or_null(datetime_utils_DateTimeUtils_9($_g, $dt, $format, $pos, $prevPos, $str)) . _hx_string_or_null(datetime_utils_DateTimeUtils_10($_g, $dt, $format, $pos, $prevPos, $str)); break; case 82: $str .= _hx_string_or_null(datetime_utils_DateTimeUtils_11($_g, $dt, $format, $pos, $prevPos, $str)) . _hx_string_or_null(datetime_utils_DateTimeUtils_12($_g, $dt, $format, $pos, $prevPos, $str)); break; case 83: $s17 = _hx_string_rec(Std::int($dt - Math::ffloor($dt / 60) * 60), "") . ""; if (strlen("0") === 0 || strlen($s17) >= 2) { $str .= _hx_string_or_null($s17); } else { $str .= _hx_string_or_null(str_pad($s17, Math::ceil((2 - strlen($s17)) / strlen("0")) * strlen("0") + strlen($s17), "0", STR_PAD_LEFT)); } break; case 84: $str .= _hx_string_or_null(datetime_utils_DateTimeUtils_13($_g, $dt, $format, $pos, $prevPos, $str)) . _hx_string_or_null(datetime_utils_DateTimeUtils_14($_g, $dt, $format, $pos, $prevPos, $str)) . _hx_string_or_null(datetime_utils_DateTimeUtils_15($_g, $dt, $format, $pos, $prevPos, $str)); break; case 68: $str .= _hx_string_or_null(datetime_utils_DateTimeUtils_16($_g, $dt, $format, $pos, $prevPos, $str)) . _hx_string_or_null(datetime_utils_DateTimeUtils_17($_g, $dt, $format, $pos, $prevPos, $str)) . _hx_string_or_null(datetime_utils_DateTimeUtils_18($_g, $dt, $format, $pos, $prevPos, $str)); break; case 70: $str .= _hx_string_rec(datetime__DateTime_DateTime_Impl_::getYear($dt), "") . "-" . _hx_string_or_null(datetime_utils_DateTimeUtils_19($_g, $dt, $format, $pos, $prevPos, $str)) . _hx_string_or_null(datetime_utils_DateTimeUtils_20($_g, $dt, $format, $pos, $prevPos, $str)); break; case 115: $str .= _hx_string_rec($dt - 62135596800.0, "") . ""; break; case 37: $str .= "%"; break; } unset($_g); $prevPos = $pos + 1; $pos = _hx_index_of($format, "%", $pos + 1); } $str .= _hx_string_or_null(_hx_substring($format, $prevPos, null)); return $str; }