Feature #27417

DateTime conversion support

Added by Robert Lemke about 4 years ago. Updated about 4 years ago.

Status:Resolved Start date:2011-06-14
Priority:Should have Due date:
Assigned To:Bastian Waidelich % Done:

100%

Category:Property
Target version:TYPO3 Flow Base Distribution - 1.0 beta 1
PHP Version: Complexity:
Has patch:

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 Magnifier (4.3 kB) Bastian Waidelich, 2011-06-14 01:13

ArrayToDateTimeConverter.php Magnifier (3.8 kB) Robert Lemke, 2011-06-16 16:32

ArrayToDateTimeConverterTest.php Magnifier (4.3 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 beha... Resolved 2012-12-25
duplicated by TYPO3.Flow - Feature #29564: Change \TYPO3\FLOW3\Property\TypeConverter\DateTimeConver... Closed 2011-09-08

Associated revisions

Revision f8f3fc23
Added by Bastian Waidelich about 4 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 about 4 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 about 4 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 about 4 years ago

  • Assigned To 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 about 4 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 about 4 years ago

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

#6 Updated by Mr. Hudson about 4 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 about 4 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:

 1<input type="hidden" name="newPost[date][dateFormat]" value="d.m.Y" />
 2<label for="date">Date (d.m.Y)</label>
 3<input type="text" name="newPost[date][date]" id="date" />
 4<label for="hour">Time</label>
 5<select name="newPost[date][hour]" id="hour">
 6    <option value="1">01</option>
 7    [...]
 8</select>:
 9<select name="newPost[date][minute]" id="minute">
10    <option value="1">01</option>
11    [...]
12</select>
13<label for="timezone">Timezone</label>
14<select name="newPost[date][timezone]" id="timezone">
15    <option value="Africa/Abidjan">Africa/Abidjan</option>
16    [...]
17</select>

#8 Updated by Mr. Hudson about 4 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 about 4 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 about 4 years ago

  • Status changed from Accepted to Under Review

#11 Updated by Bastian Waidelich about 4 years ago

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

Also available in: Atom PDF