Feature #27417

DateTime conversion support

Added by Robert Lemke over 8 years ago. Updated over 8 years ago.

Status:
Resolved
Priority:
Should have
Category:
Property
Start date:
2011-06-14
Due date:
% Done:

100%

PHP Version:
Has patch:
Complexity:

Description

It should be possible to submit a date through a form via POST and receive a date time object as an argument in a controller. Hence we need a Type Converter supporting array to DateTime conversion. The input format should be configurable, unix timestamp would be a good default.

StringToDateTimeConverter.php View (4.32 KB) Bastian Waidelich, 2011-06-14 01:13

ArrayToDateTimeConverter.php View (3.77 KB) Robert Lemke, 2011-06-16 16:32

ArrayToDateTimeConverterTest.php View (4.32 KB) Robert Lemke, 2011-06-16 16:32


Related issues

Related to TYPO3.Flow - Feature #5660: Implement support for Object Converters Resolved 2009-12-07
Related to TYPO3.Flow - Bug #35369: DateTimeConverter's timezone key leads to unexpected behavior Resolved 2012-12-25
Duplicated by TYPO3.Flow - Feature #29564: Change \TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter in order to compose a DateTime property from two input fields Closed 2011-09-08

Associated revisions

Revision f8f3fc23 (diff)
Added by Bastian Waidelich over 8 years ago

[FEATURE] DateTime conversion support

This adds a new Type Converter which is capable of converting dates
given as string into DateTime objects. The source can be either of
type string or array.

By default it expects the string in the format "Y-m-d\TH:i:sP"
(= DateTime::W3C) but this can be overridden via MappingConfiguration.

If source is an array, expected date format, time and timezone can
be overridden from the source as well:

Example for a Fluid form (snippet):

<f:form.hidden name="newPost[date][format]" value="d.m.Y - H:i:s" />
<input type="text" name="newPost[date][date]" id="date" /><br />

See #27417 for a more advanced sample.

Change-Id: I61e7038d89fe0a3a79ee85b3f81250244c1d12df
Resolves: #27417

History

#1 Updated by Bastian Waidelich over 8 years ago

Hi Robert,

we need this for the next sprint release for the T3CON11 site, so I started working on this before the weekend.
Attached my first version, hope that helps.

#2 Updated by Bastian Waidelich over 8 years ago

A few more notes after quickly discussing this with Sebastian:
- We probably shouldn't use Timestamp as default date format as its timezone dependent
- The default date should be an ISO date format that also contains the time
- The DateTimeConverter might also support an array that contains the format string

I'll take care of the above changes and push a version to gerrit (to the FLOW3 package) if no-one objects. @Robert if you already started working on this, let me know.

#3 Updated by Bastian Waidelich over 8 years ago

  • Assignee changed from Robert Lemke to Bastian Waidelich

I am so bold as to overtake this issue because I'm currently working on this (see above).

#4 Updated by Mr. Hudson over 8 years ago

Patch set 1 of change I61e7038d89fe0a3a79ee85b3f81250244c1d12df has been pushed to the review server.
It is available at http://review.typo3.org/2762

#5 Updated by Robert Lemke over 8 years ago

For the record I attached the DateTimeConverter I've been coding in San Francisco.

#6 Updated by Mr. Hudson over 8 years ago

Patch set 2 of change I61e7038d89fe0a3a79ee85b3f81250244c1d12df has been pushed to the review server.
It is available at http://review.typo3.org/2762

#7 Updated by Bastian Waidelich over 8 years ago

  • Subject changed from Basic DateTime conversion support to DateTime conversion support

With the new changeset I have just pushed, it is possible to override dateFormat, time and timezone on the client side:

<input type="hidden" name="newPost[date][dateFormat]" value="d.m.Y" />
<label for="date">Date (d.m.Y)</label>
<input type="text" name="newPost[date][date]" id="date" />
<label for="hour">Time</label>
<select name="newPost[date][hour]" id="hour">
    <option value="1">01</option>
    [...]
</select>:
<select name="newPost[date][minute]" id="minute">
    <option value="1">01</option>
    [...]
</select>
<label for="timezone">Timezone</label>
<select name="newPost[date][timezone]" id="timezone">
    <option value="Africa/Abidjan">Africa/Abidjan</option>
    [...]
</select>

#8 Updated by Mr. Hudson over 8 years ago

Patch set 3 of change I61e7038d89fe0a3a79ee85b3f81250244c1d12df has been pushed to the review server.
It is available at http://review.typo3.org/2762

#9 Updated by Mr. Hudson over 8 years ago

Patch set 4 of change I61e7038d89fe0a3a79ee85b3f81250244c1d12df has been pushed to the review server.
It is available at http://review.typo3.org/2762

#10 Updated by Bastian Waidelich over 8 years ago

  • Status changed from Accepted to Under Review

#11 Updated by Bastian Waidelich over 8 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF