ILIAS
release_7 Revision v7.30-3-g800a261c036
◀ ilDoc Overview
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
$
_
a
b
c
d
e
f
g
h
i
j
l
m
p
r
s
t
w
+
Functions
_
a
b
c
f
g
h
i
r
s
t
w
+
Variables
$
c
d
e
f
g
h
j
l
m
p
s
t
+
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
+
Data Fields
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
$
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Files
File List
+
Globals
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
+
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
+
Variables
$
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Modules
Pages
DateTimeTransformation.php
Go to the documentation of this file.
1
<?php declare(strict_types=1);
2
3
/* Copyright (c) 2020 Luka K. A. Stocker, Extended GPL, see docs/LICENSE */
4
5
namespace
ILIAS\Refinery\KindlyTo\Transformation
;
6
7
use
ILIAS\Refinery\ConstraintViolationException
;
8
use
ILIAS\Refinery\DeriveApplyToFromTransform
;
9
use
ILIAS\Refinery\DeriveInvokeFromTransform
;
10
use
ILIAS\Refinery\Transformation
;
11
19
class
DateTimeTransformation
implements
Transformation
20
{
21
use
DeriveApplyToFromTransform
;
22
use
DeriveInvokeFromTransform
;
23
27
public
function
transform
($from)
28
{
29
if
($from instanceof \
DateTimeImmutable
) {
30
return
$from;
31
}
32
33
$formats
= [
34
\DateTimeImmutable::ATOM,
35
\DateTimeImmutable::COOKIE,
36
\DateTimeImmutable::ISO8601,
37
\DateTimeImmutable::RFC822,
38
\DateTimeImmutable::RFC7231,
39
\DateTimeImmutable::RFC3339_EXTENDED
40
];
41
42
if
(is_string($from)) {
43
foreach
(
$formats
as
$format
) {
44
$res
= \DateTimeImmutable::createFromFormat($format, $from);
45
if
(
$res
instanceof \DateTimeImmutable) {
46
return
$res
;
47
}
48
}
49
}
50
51
if
(is_int($from) || is_float($from)) {
52
return
new \DateTimeImmutable(
"@"
. round($from));
53
}
54
55
throw
new
ConstraintViolationException
(
56
sprintf(
'Value "%s" could not be transformed.'
, $from),
57
'no_valid_datetime'
,
58
$from
59
);
60
}
61
}
DateTimeImmutable
ILIAS\Refinery\KindlyTo\Transformation\DateTimeTransformation\transform
transform($from)
Perform the transformation.Please use this for transformations. It's more performant than calling inv...
Definition:
DateTimeTransformation.php:27
ILIAS\Refinery\KindlyTo\Transformation\DateTimeTransformation
Transform date format to DateTimeImmutable Please note:
Definition:
DateTimeTransformation.php:19
Transformation
ILIAS\Refinery\DeriveApplyToFromTransform
trait DeriveApplyToFromTransform
Definition:
DeriveApplyToFromTransform.php:13
ILIAS\Refinery\DeriveInvokeFromTransform
trait DeriveInvokeFromTransform
Definition:
DeriveInvokeFromTransform.php:13
ILIAS\Refinery\ConstraintViolationException
Definition:
ConstraintViolationException.php:14
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
$format
$format
Definition:
metadata.php:218
ILIAS\Refinery\Transformation
A transformation is a function from one datatype to another.
Definition:
Transformation.php:17
ConstraintViolationException
$formats
$formats
Definition:
date.php:77
ILIAS\Refinery\KindlyTo\Transformation
Definition:
BooleanTransformation.php:5
src
Refinery
KindlyTo
Transformation
DateTimeTransformation.php
Generated on Tue Apr 15 2025 21:01:36 for ILIAS by
1.8.13 (using
Doxyfile
)