diff --git a/docs/relay/dev/datetime.md b/docs/relay/dev/datetime.md index 7487b01b67c4a59bbc9c7407ab0cc601ef8be052..2fb68421f1ee70df9567c7bb7d80601770374b77 100644 --- a/docs/relay/dev/datetime.md +++ b/docs/relay/dev/datetime.md @@ -1,4 +1,4 @@ -# DateTime Handling in the API and PHP +# DateTime/Duration Handling in the API, PHP and Config Recommendations: @@ -49,3 +49,20 @@ Convert a `DateTimeImmutable` with a non-UTC timezone to UTC: $datetime = new \DateTimeImmutable('2022-10-20T08:28:49+02:00'); $datetime->setTimezone(new \DateTimeZone('UTC')); ``` + +## Durations + +Use ISO durations in the config as well as in the API for durations. + +If possible use a start and/or end DateTime in the API response, so the client +doesn't have to deal with durations. + +Otherwise use ISO 8601 durations, in the bundle config, API and PHP: + +```php +new \DateInterval('P1Y'); +new \DateInterval('PT60S'); +``` + +Note that the PHP implementation is limited and doesn't allow decimal numbers or +no negative numbers, so we can't support them either.