1
1
<?php
2
2
declare (strict_types=1 );
3
3
4
+ namespace PHP81_BC \Tests ;
5
+
6
+ use DateTime ;
7
+ use DateTimeImmutable ;
8
+ use InvalidArgumentException ;
4
9
use PHPUnit \Framework \TestCase ;
5
10
use function PHP81_BC \strftime ;
6
11
7
12
class strftimeTest extends TestCase {
13
+ use LocaleFormatterTestTrait;
8
14
9
- public function setUp () : void {
15
+ public static function setUpBeforeClass () : void {
10
16
date_default_timezone_set ('Europe/Madrid ' );
11
17
}
12
18
@@ -166,23 +172,6 @@ public function testMiscellaneousFormats () {
166
172
$ this ->assertEquals ('% ' , $ result , '%%: A literal percentage character ("%") ' );
167
173
}
168
174
169
- public function testLocale () {
170
- $ result = strftime ('%x %X ' , '20220306 13:02:03 ' , 'it_IT ' );
171
- $ this ->assertEquals ('06/03/22 13:02:03 ' , $ result , 'Locale test for it_IT ' );
172
-
173
- $ result = strftime ('%x %X ' , '20220306 13:02:03 ' , 'it_CH ' );
174
- $ this ->assertEquals ('06.03.22 13:02:03 ' , $ result , 'Locale test for it_CH ' );
175
-
176
- $ result = strftime ('%c ' , '20220306 13:02:03 ' , 'eu ' );
177
- $ this ->assertEquals ('2022(e)ko martxoaren 6(a) 13:02 ' , $ result , '%c: Preferred date and time stamp based on locale ' );
178
-
179
- $ result = strftime ('%b ' , '20220306 13:02:03 ' , 'eu ' );
180
- $ this ->assertEquals ('mar. ' , $ result , '%b: Abbreviated month name, based on the locale ' );
181
-
182
- $ result = strftime ('%B ' , '20220306 13:02:03 ' , 'eu ' );
183
- $ this ->assertEquals ('martxoa ' , $ result , '%B: Full month name, based on the locale ' );
184
- }
185
-
186
175
/**
187
176
* In October 1582, the Gregorian calendar replaced the Julian in much of Europe, and
188
177
* the 4th October was followed by the 15th October.
@@ -195,17 +184,17 @@ public function testLocale () {
195
184
public function testJulianCutover () {
196
185
// 1st October 1582 in proleptic Gregorian is the same date as 21st September 1582 Julian
197
186
$ prolepticTimestamp = DateTimeImmutable::createFromFormat ('Y-m-d| ' , '1582-10-01 ' )->getTimestamp ();
198
- $ result = strftime ('%x ' , $ prolepticTimestamp , 'eu ' );
199
- $ this ->assertEquals ('82/10/1 ' , $ result , '1st October 1582 in proleptic Gregorian is the same date as 21st September 1582 Julian ' );
187
+ $ result = strftime ('%F: % x ' , $ prolepticTimestamp , 'en-EN ' );
188
+ $ this ->assertEquals ('1582-10-01: 10/1/82 ' , $ result , '1st October 1582 in proleptic Gregorian is the same date as 21st September 1582 Julian ' );
200
189
201
190
// In much of Europe, the 10th October 1582 never existed
202
191
$ prolepticTimestamp = DateTimeImmutable::createFromFormat ('Y-m-d| ' , '1582-10-10 ' )->getTimestamp ();
203
- $ result = strftime ('%x ' , $ prolepticTimestamp , 'eu ' );
204
- $ this ->assertEquals ('82/10 /10 ' , $ result , 'In much of Europe, the 10th October 1582 never existed ' );
192
+ $ result = strftime ('%F: % x ' , $ prolepticTimestamp , 'en-EN ' );
193
+ $ this ->assertEquals ('1582-10-10: 10 /10/82 ' , $ result , 'In much of Europe, the 10th October 1582 never existed ' );
205
194
206
195
// The 15th October was the first day after the cutover, after which both systems agree
207
196
$ prolepticTimestamp = DateTimeImmutable::createFromFormat ('Y-m-d| ' , '1582-10-15 ' )->getTimestamp ();
208
- $ result = strftime ('%x ' , $ prolepticTimestamp , 'eu ' );
209
- $ this ->assertEquals ('82/10 /15 ' , $ result , 'The 15th October was the first day after the cutover, after which both systems agree ' );
197
+ $ result = strftime ('%F: % x ' , $ prolepticTimestamp , 'en-EN ' );
198
+ $ this ->assertEquals ('1582-10-15: 10 /15/82 ' , $ result , 'The 15th October was the first day after the cutover, after which both systems agree ' );
210
199
}
211
200
}
0 commit comments