Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add time functions #1150

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions builtin-functions/kphp-light/functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require_once __DIR__ . '/job-workers.txt';
require_once __DIR__ . '/rpc.txt';
require_once __DIR__ . '/string.txt';
require_once __DIR__ . '/kphp-toggles.txt';
require_once __DIR__ . '/time.txt';

/** defined in runtime-core.h **/
function likely ($x ::: bool) ::: bool;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<?php

// ===== SUPPORTED =====

function mktime (int $hour, ?int $minute = null, ?int $second = null,
?int $month = null, ?int $day = null, ?int $year = null) ::: int;

function date ($format ::: string, $timestamp ::: ?int = null) ::: string;

function date_default_timezone_set ($s ::: string) ::: bool;

function gmdate ($format ::: string, $timestamp ::: ?int = null) ::: string;

function time() ::: int;

// ===== UNSUPPORTED =====

/** @kphp-generate-stub-class */
class DateInterval {
/** @kphp-extern-func-info can_throw generate-stub */
Expand Down Expand Up @@ -144,22 +159,15 @@ define('DATE_RFC3339', "Y-m-d\TH:i:sP");
define('DATE_RSS', "D, d M Y H:i:s O");
define('DATE_W3C', "Y-m-d\TH:i:sP");

/** @kphp-extern-func-info generate-stub */
function date ($format ::: string, $timestamp ::: int = PHP_INT_MIN) ::: string;
/** @kphp-extern-func-info generate-stub */
function date_default_timezone_set ($s ::: string) ::: bool;
/** @kphp-extern-func-info generate-stub */
function date_default_timezone_get() ::: string;
/** @kphp-extern-func-info generate-stub */
function getdate ($timestamp ::: int = PHP_INT_MIN) ::: mixed[];
/** @kphp-extern-func-info generate-stub */
function gmdate ($format ::: string, $timestamp ::: int = PHP_INT_MIN) ::: string;
/** @kphp-extern-func-info generate-stub */
function gmmktime ($h ::: int = PHP_INT_MIN, $m ::: int = PHP_INT_MIN, $s ::: int = PHP_INT_MIN, $month ::: int = PHP_INT_MIN, $day ::: int = PHP_INT_MIN, $year ::: int = PHP_INT_MIN) ::: int;
/** @kphp-extern-func-info generate-stub */
function hrtime (bool $as_number = false): mixed; // int[]|int
/** @kphp-extern-func-info generate-stub */
function mktime ($h ::: int = PHP_INT_MIN, $m ::: int = PHP_INT_MIN, $s ::: int = PHP_INT_MIN, $month ::: int = PHP_INT_MIN, $day ::: int = PHP_INT_MIN, $year ::: int = PHP_INT_MIN) ::: int;

/** @kphp-extern-func-info generate-stub */
function localtime ($timestamp ::: int = PHP_INT_MIN, $is_associative ::: bool = false) ::: mixed[];
/** @kphp-extern-func-info generate-stub */
Expand All @@ -168,8 +176,6 @@ function microtime ($get_as_float ::: bool = false) ::: mixed;
function strftime ($format ::: string, $timestamp ::: int = PHP_INT_MIN) ::: string;
/** @kphp-extern-func-info generate-stub */
function strtotime ($time ::: string, $timestamp ::: int = PHP_INT_MIN) ::: int | false;
/** @kphp-extern-func-info generate-stub */
function time() ::: int;


/** @kphp-extern-func-info generate-stub */
Expand Down
1 change: 0 additions & 1 deletion builtin-functions/kphp-light/unsupported-functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ require_once __DIR__ . '/unsupported/regex.txt';
require_once __DIR__ . '/unsupported/serialize.txt';
require_once __DIR__ . '/unsupported/server.txt';
require_once __DIR__ . '/unsupported/spl.txt';
require_once __DIR__ . '/unsupported/time.txt';
require_once __DIR__ . '/unsupported/uberh3.txt';
require_once __DIR__ . '/unsupported/vkext.txt';
1 change: 1 addition & 0 deletions runtime-light/stdlib/stdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ prepend(
rpc/rpc-tl-request.cpp
string/string-state.cpp
system/system-state.cpp
time/time-functions.cpp
file/file-stream-state.cpp)
Loading
Loading