Skip to content

Commit 64a1391

Browse files
committed
Add DateTimeValue::now
1 parent 2155a18 commit 64a1391

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"ext-pcre": "*",
4343
"ext-spl": "*",
4444

45+
"psr/clock": "~1.0",
4546
"simplesamlphp/assert": "~1.9",
4647
"simplesamlphp/composer-xmlprovider-installer": "~1.2"
4748
},

src/XMLSchema/Type/DateTimeValue.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use DateTimeImmutable;
88
use DateTimeInterface;
9+
use Psr\Clock\ClockInterface;
910
use SimpleSAML\XML\Assert\Assert;
1011
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
1112
use SimpleSAML\XMLSchema\Type\Interface\AbstractAnySimpleType;
@@ -47,6 +48,15 @@ protected function validateValue(string $value): void
4748
}
4849

4950

51+
/**
52+
* @return static
53+
*/
54+
public static function now(ClockInterface $clock): static
55+
{
56+
return static::fromDateTime($clock->now());
57+
}
58+
59+
5060
/**
5161
* @param \DateTimeInterface $value
5262
* @return static

0 commit comments

Comments
 (0)