File tree Expand file tree Collapse file tree 3 files changed +75
-0
lines changed
templates/_includes/fields Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace craft \feedme \fields ;
4+
5+ use Cake \Utility \Hash ;
6+ use craft \feedme \base \Field ;
7+ use craft \feedme \base \FieldInterface ;
8+ use craft \feedme \helpers \DateHelper ;
9+ use craft \fields \Time as TimeField ;
10+
11+ /**
12+ *
13+ * @property-read string $mappingTemplate
14+ */
15+ class Time extends Field implements FieldInterface
16+ {
17+ // Properties
18+ // =========================================================================
19+
20+ /**
21+ * @var string
22+ */
23+ public static string $ name = 'Time ' ;
24+
25+ /**
26+ * @var string
27+ */
28+ public static string $ class = TimeField::class;
29+
30+ // Templates
31+ // =========================================================================
32+
33+ /**
34+ * @inheritDoc
35+ */
36+ public function getMappingTemplate (): string
37+ {
38+ return 'feed-me/_includes/fields/time ' ;
39+ }
40+
41+ // Public Methods
42+ // =========================================================================
43+
44+ /**
45+ * @inheritDoc
46+ */
47+ public function parseField (): mixed
48+ {
49+ $ value = $ this ->fetchValue ();
50+
51+ if ($ value === null ) {
52+ return null ;
53+ }
54+
55+ $ formatting = Hash::get ($ this ->fieldInfo , 'options.match ' );
56+
57+ $ timeValue = DateHelper::parseString ($ value , $ formatting );
58+
59+ if ($ timeValue ) {
60+ return $ timeValue ;
61+ }
62+
63+ return $ value ;
64+ }
65+ }
Original file line number Diff line number Diff line change 3737use craft \feedme \fields \SuperTable ;
3838use craft \feedme \fields \Table ;
3939use craft \feedme \fields \Tags ;
40+ use craft \feedme \fields \Time ;
4041use craft \feedme \fields \TypedLink ;
4142use craft \feedme \fields \Users ;
4243use craft \helpers \Component as ComponentHelper ;
@@ -140,6 +141,7 @@ public function getRegisteredFields(): array
140141 RadioButtons::class,
141142 Table::class,
142143 Tags::class,
144+ Time::class,
143145 Users::class,
144146
145147 // Third-Party
Original file line number Diff line number Diff line change 1+ {% import 'feed-me/_macros' as feedMeMacro %}
2+ {% import '_includes/forms' as forms %}
3+
4+ {% set default = default ?? {
5+ type: 'time',
6+ } %}
7+
8+ {% extends 'feed-me/_includes/fields/date' %}
You can’t perform that action at this time.
0 commit comments