-
Notifications
You must be signed in to change notification settings - Fork 35
A DateTime filter #85
base: develop
Are you sure you want to change the base?
Conversation
This is a new filter that returns DateTime or (if desired) DateTimeImmutable instances.
@gscscnd https://github.com/zendframework/zend-filter/blob/master/src/DateTimeFormatter.php |
@froschdesign, it seems that |
@gscscnd The following filtering is support:
Is this correct or did I forget something? |
Actually I don’t check if a
Also |
We have to explicitly define all possible values for the filtering - input and ouput. Otherwise, we can not write the full documentation and all required unit tests.
This means:
|
We can throw an Anyway:
|
@gscscnd
No exceptions are allowed during the process of filtering. If the given value can not be handled by the filter, the value should be returned unfiltered.
Does the filter create a new object each time or will the same object returned? Can you describe the typical use case for this filter? Thanks! |
🆗, will fix that. (Current code doesn’t throw exceptions explicitly, but setting
Returns the same instance.
I’ve got a form (or any array of data, for that matter) with a datetime‑like input and an entity with a datetime‑like property. I setup an InputFilter with a Date validator and a DateTime filter. The input array contains |
@gscscnd
If you use zend-hydrator already then you can use |
Well, I didn’t know about it. Thanks for the pointer! |
This repository has been closed and moved to laminas/laminas-filter; a new issue has been opened at laminas/laminas-filter#1. |
This repository has been moved to laminas/laminas-filter. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:
|
This is a new filter that returns
DateTime
or (if desired)DateTimeImmutable
instances.