DateTime[Immutable]::createFromTimestamp(float) misses support for 64bit integers or 32bit environments
未关闭
还没有人认领这个 Issue。
Bug
Extension: date
Status: Needs Triage
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.1k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
The following code:
<?php
$dt = DateTime::createFromFormat('U', '2147483647');
var_dump($dt);
$dt = $dt->modify('+1 second');
var_dump($dt);
$ts = $dt->format('U');
$tsf = (float)$ts;
var_dump($ts, $tsf);
$dt2 = DateTime::createFromTimestamp($tsf);
Resulted in this output:
object(DateTime)#1 (3) {
["date"]=>
string(26) "2038-01-19 03:14:07.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+00:00"
}
object(DateTime)#1 (3) {
["date"]=>
string(26) "2038-01-19 03:14:08.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+00:00"
}
string(10) "2147483648"
float(2147483648)
Fatal error: Uncaught DateRangeError: DateTime::createFromTimestamp(): Argument #1 ($timestamp) must be a finite number between -2147483648 and 2147483647.999999, 2.14748e+9 given
But I expected this output instead:
object(DateTime)#1 (3) {
["date"]=>
string(26) "2038-01-19 03:14:07.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+00:00"
}
object(DateTime)#1 (3) {
["date"]=>
string(26) "2038-01-19 03:14:08.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+00:00"
}
string(10) "2147483648"
float(2147483648)
object(DateTime)#2 (3) {
["date"]=>
string(26) "2038-01-19 03:14:08.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+00:00"
}
PHP Version
>= PHP 8.4
Operating System
32bit environment
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 DateTime::createFromTimestamp() 入口点开始,并在 32 位环境中重现该示例,重点关注浮点值 2147483648。完成的标准是接受该值并生成预期的 2038-01-19 03:14:08 DateTime,而不是 DateRangeError。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, php
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 48/100