File: Update-tests-for-EN-datetime-locale-change-to-space.diff

package info (click to toggle)
request-tracker5 5.0.3%2Bdfsg-3~deb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 77,648 kB
  • sloc: javascript: 187,930; perl: 79,061; sh: 1,302; makefile: 471; python: 37; php: 15
file content (123 lines) | stat: -rw-r--r-- 5,840 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
From 209637ab6be6d3d3142eebc4d87494801bf6b6d0 Mon Sep 17 00:00:00 2001
From: Jim Brandt <jbrandt@bestpractical.com>
Date: Mon, 7 Nov 2022 17:18:48 -0500
Subject: Update tests for EN datetime locale change to space

This patch has been cherry-picked from upstream 5.0-trunk. It can be
dropped once we import 5.0.4 (when it is released).

DateTime::Locale version 1.58 published CLDR 42.0.0 which changed
the space character in times before the AM and PM to be
U+202F NARROW NO-BREAK SPACE (aka NNBSP) from the previous
space (U+0020). This broke tests looking for a space character
for localized datetimes with an AM/PM.

Update to a like test to work for older versions of DateTime::Locale
and for new ones from 1.58 forward.

Forwarded: not-needed
Patch-Name: Update-tests-for-EN-datetime-locale-change-to-space.diff
---
 t/api/date.t | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/t/api/date.t b/t/api/date.t
index 19a0a015..aee517d9 100644
--- a/t/api/date.t
+++ b/t/api/date.t
@@ -81,6 +81,11 @@ my $current_user;
     RT->Config->Set( Timezone => 'UTC' );
 }
 
+# Note, starting with DateTime::Locale version 1.58,
+# RT::Date::LocalizedDateTime returns AM/PM with a
+# U+202F NARROW NO-BREAK SPACE (aka NNBSP) before them rather than
+# a plain space, thus the "like" tests below.
+
 {
     my $date = RT::Date->new(RT->SystemUser);
     is($date->IsSet,0, "new date isn't set");
@@ -97,8 +102,8 @@ my $current_user;
     is($date->Get(Format =>'RFC2822'),
        'Thu, 01 Jan 1970 00:00:00 +0000',
        "RFC2822 format with defaults");
-    is($date->Get(Format =>'LocalizedDateTime'),
-       'Thu, Jan 1, 1970 12:00:00 AM',
+    like($date->Get(Format =>'LocalizedDateTime'),
+       qr/Thu\, Jan 1\, 1970 12:00:00( |\x{202F})AM/,
        "LocalizedDateTime format with defaults");
 
     is($date->ISO(Time => 0),
@@ -123,8 +128,8 @@ my $current_user;
     is($date->RFC2822(Date => 0),
        '00:00:00 +0000',
        "RFC2822 format without date part");
-    is($date->LocalizedDateTime(Date => 0),
-       '12:00:00 AM',
+    like($date->LocalizedDateTime(Date => 0),
+       qr/12:00:00( |\x{202F})AM/,
        "LocalizedDateTime format without date part");
 
     is($date->ISO(Date => 0, Seconds => 0),
@@ -144,17 +149,17 @@ my $current_user;
        '00:00:00 +0000',
        "RFC2822 format without 'day of week' and date parts(corner case test)");
 
-    is($date->LocalizedDateTime(AbbrDay => 0),
-       'Thursday, Jan 1, 1970 12:00:00 AM',
+    like($date->LocalizedDateTime(AbbrDay => 0),
+       qr/Thursday\, Jan 1\, 1970 12:00:00( |\x{202F})AM/,
        "LocalizedDateTime format without abbreviation of day");
-    is($date->LocalizedDateTime(AbbrMonth => 0),
-       'Thu, January 1, 1970 12:00:00 AM',
+    like($date->LocalizedDateTime(AbbrMonth => 0),
+       qr/Thu\, January 1\, 1970 12:00:00( |\x{202F})AM/,
        "LocalizedDateTime format without abbreviation of month");
-    is($date->LocalizedDateTime(DateFormat => 'date_format_short'),
-       '1/1/70 12:00:00 AM',
+    like($date->LocalizedDateTime(DateFormat => 'date_format_short'),
+       qr/1\/1\/70 12:00:00( |\x{202F})AM/,
        "LocalizedDateTime format with non default DateFormat");
-    is($date->LocalizedDateTime(TimeFormat => 'time_format_short'),
-       'Thu, Jan 1, 1970 12:00 AM',
+    like($date->LocalizedDateTime(TimeFormat => 'time_format_short'),
+       qr/Thu\, Jan 1\, 1970 12:00( |\x{202F})AM/,
        "LocalizedDateTime format with non default TimeFormat");
 
     is($date->Date,
@@ -212,7 +217,7 @@ my $current_user;
     is($date->ISO( Timezone => 'user' ), '2005-01-01 18:10:00', "ISO");
     is($date->W3CDTF( Timezone => 'user' ), '2005-01-01T18:10:00+03:00', "W3C DTF");
     is($date->RFC2822( Timezone => 'user' ), 'Sat, 01 Jan 2005 18:10:00 +0300', "RFC2822");
-    is($date->LocalizedDateTime( Timezone => 'user' ), 'Sat, Jan 1, 2005 6:10:00 PM', "LocalizedDateTime");
+    like($date->LocalizedDateTime( Timezone => 'user' ), qr/Sat\, Jan 1\, 2005 6:10:00( |\x{202F})PM/, "LocalizedDateTime");
 
     # DST
     $date = RT::Date->new( $current_user );
@@ -220,7 +225,7 @@ my $current_user;
     is($date->ISO( Timezone => 'user' ), '2005-07-01 19:10:00', "ISO");
     is($date->W3CDTF( Timezone => 'user' ), '2005-07-01T19:10:00+04:00', "W3C DTF");
     is($date->RFC2822( Timezone => 'user' ), 'Fri, 01 Jul 2005 19:10:00 +0400', "RFC2822");
-    is($date->LocalizedDateTime( Timezone => 'user' ), 'Fri, Jul 1, 2005 7:10:00 PM', "LocalizedDateTime");
+    like($date->LocalizedDateTime( Timezone => 'user' ), qr/Fri\, Jul 1\, 2005 7:10:00( |\x{202F})PM/, "LocalizedDateTime");
 }
 
 { # negative timezone
@@ -230,7 +235,7 @@ my $current_user;
     is($date->ISO( Timezone => 'user' ), '2005-01-01 10:10:00', "ISO");
     is($date->W3CDTF( Timezone => 'user' ), '2005-01-01T10:10:00-05:00', "W3C DTF");
     is($date->RFC2822( Timezone => 'user' ), 'Sat, 01 Jan 2005 10:10:00 -0500', "RFC2822");
-    is($date->LocalizedDateTime( Timezone => 'user' ), 'Sat, Jan 1, 2005 10:10:00 AM', "LocalizedDateTime");
+    like($date->LocalizedDateTime( Timezone => 'user' ), qr/Sat\, Jan 1\, 2005 10:10:00( |\x{202F})AM/, "LocalizedDateTime");
 
     # DST
     $date = RT::Date->new( $current_user );
@@ -238,7 +243,7 @@ my $current_user;
     is($date->ISO( Timezone => 'user' ), '2005-07-01 11:10:00', "ISO");
     is($date->W3CDTF( Timezone => 'user' ), '2005-07-01T11:10:00-04:00', "W3C DTF");
     is($date->RFC2822( Timezone => 'user' ), 'Fri, 01 Jul 2005 11:10:00 -0400', "RFC2822");
-    is($date->LocalizedDateTime( Timezone => 'user' ), 'Fri, Jul 1, 2005 11:10:00 AM', "LocalizedDateTime");
+    like($date->LocalizedDateTime( Timezone => 'user' ), qr/Fri\, Jul 1\, 2005 11:10:00( |\x{202F})AM/, "LocalizedDateTime");
 }
 
 warning_like