@@ -30,7 +30,12 @@ Available float types
3030---------------------
3131
3232- PhpTypedValues\Float\FloatBasic — any PHP float
33- - PhpTypedValues\Float\PositiveFloat — positive float (> 0)
33+ - PhpTypedValues\Float\NonNegativeFloat — zero or positive float (>= 0)
34+
35+ Available DateTime types
36+ ------------------------
37+
38+ - PhpTypedValues\DateTime\DateTimeBasic — immutable DateTime value; parses common ISO-8601 formats
3439
3540Quick start
3641-----------
@@ -62,7 +67,13 @@ use PhpTypedValues\Float\FloatBasic;
6267use PhpTypedValues\Float\NonNegativeFloat;
6368
6469$price = FloatBasic::fromString('19.99');
65- $ratio = new NonNegativeFloat(0.5); // > 0
70+ $ratio = new NonNegativeFloat(0.5); // >= 0 allowed
71+
72+ // DateTime
73+ use PhpTypedValues\DateTime\DateTimeBasic;
74+
75+ $dt = DateTimeBasic::fromString('2025-01-02T03:04:05+00:00');
76+ echo $dt->toString(); // "2025-01-02T03:04:05+00:00"
6677
6778// Accessing the raw value and string form
6879echo $pos->value(); // 1
@@ -79,14 +90,16 @@ Invalid input throws an exception with a helpful message.
7990use PhpTypedValues\Integer\PositiveInt;
8091use PhpTypedValues\String\NonEmptyStr;
8192use PhpTypedValues\Float\NonNegativeFloat;
93+ use PhpTypedValues\DateTime\DateTimeBasic;
8294
8395new PositiveInt(0); // throws: Value must be a positive integer
8496PositiveInt::fromString('12.3'); // throws: String has no valid integer
8597
8698new NonEmptyStr(''); // throws: Value must be a non-empty string
8799
88- new NonNegativeFloat(0.0); // throws: Value must be a positive float
89100NonNegativeFloat::fromString('abc'); // throws: String has no valid float
101+
102+ DateTimeBasic::fromString('not-a-date'); // throws: String has no valid datetime
90103```
91104
92105Notes
0 commit comments