php / php/php-src

DateInterval cannot parse decimal fraction in ISO duration string

オープン
#13,977 コメント 1 件 リアクション 1 件 担当者 1 名 GitHub で見る

@derickr がすでに取り組んでいます。

2024年4月16日 から。

Extension: date Feature
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

Description

The following code:

<?php
new DateInterval('PT0.5S');

Resulted in this output:

Warning: Uncaught DateMalformedIntervalStringException: Unknown or bad format (PT0.5S)

But I expected this output instead:

DateInterval object with 500 milliseconds

The ISO Duration string can have the seconds set to a decimal fraction. I found this bug when Postgres returns Intervals with decimal fractions for seconds if required when returning a ISO8601 duration string.

From Wikipedia:

The smallest value used may also have a decimal fraction,[39] as in "P0.5Y" to indicate half a year. This decimal fraction may be specified with either a comma or a full stop, as in "P0,5Y" or "P0.5Y".

https://www.loc.gov/standards/datetime/iso-tc154-wg5_n0038_iso_wd_8601-1_2016-02-16.pdf

If necessary for a particular application the lowest order component may have a decimal fraction. The decimal fraction shall be divided from the integer part by the decimal sign specified in ISO 31-0: i.e. the comma [,] or full stop [.]. Of these, the comma is the preferred sign. If the magnitude of the number is less than unity, the decimal sign shall be preceded by a zero (see ISO 31-0);

PHP Version

PHP 8.3

Operating System

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。