Skip to content

Commit bbddd2f

Browse files
committed
#139: Additional valid EDTF inputs
1 parent 0c9b21c commit bbddd2f

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

tests/src/Kernel/EDTFFormatterTest.php

+28-13
Original file line numberDiff line numberDiff line change
@@ -158,26 +158,37 @@ public function testDateFormatting(string $input, string $expected) {
158158
*/
159159
public function edtfDateFormatProvider(): array {
160160
return [
161-
// Basic single dates.
162-
'Full date' => [
163-
'input' => '1996-04-22',
164-
// Default format.
165-
'expected' => '1996-04-22',
161+
// EDTF Level 0
162+
'Date - complete' => [
163+
'input' => '1985-04-12',
164+
'expected' => '1985-04-12',
166165
],
167-
'Year' => [
168-
'input' => '1975',
169-
'expected' => '1975',
166+
'Date - reduced precision - year and month' => [
167+
'input' => '1985-04',
168+
'expected' => '1985-04',
170169
],
171-
'Year-month' => [
172-
'input' => '2025-02',
173-
'expected' => '2025-02',
170+
'Date - reduced precision - year' => [
171+
'input' => '1985',
172+
'expected' => '1985',
174173
],
175-
'Date and time (no TZ)' => [
174+
'Date and time - local' => [
176175
'original' => '2024-10-15T12:00:00',
177176
'formatted' => '2024-10-15 12:00:00',
178177
],
178+
'Date and time - Z' => [
179+
'original' => '1985-04-12T23:20:30Z',
180+
'formatted' => '1985-04-12 23:20:30Z',
181+
],
182+
'Date and time - shift in hours' => [
183+
'original' => '1985-04-12T23:20:30+04',
184+
'formatted' => '1985-04-12 23:20:30+04',
185+
],
186+
'Date and time - shift in hours and minutes' => [
187+
'original' => '1985-04-12T23:20:30+04:30',
188+
'formatted' => '1985-04-12 23:20:30+04:30',
189+
],
179190

180-
// Uncertain/approximate dates.
191+
// EDTF level 1
181192
'Uncertain year' => [
182193
'input' => '1984?',
183194
'expected' => '1984 (year uncertain)',
@@ -198,6 +209,10 @@ public function edtfDateFormatProvider(): array {
198209
'original' => '2024-10',
199210
'formatted' => '2024-10',
200211
],
212+
'Unspecified digits from right' => [
213+
'input' => '198X',
214+
'expected' => 'Unknown year in the decade of the 1980s',
215+
],
201216

202217
// Invalid/edge cases
203218
'Empty input' => [

0 commit comments

Comments
 (0)