File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -122,13 +122,13 @@ String trimDoubleQuote(String str) {
122122}
123123
124124DateTime parseRfc7231Time (String time) {
125- final format = DateFormat ('EEE, dd MMM yyyy HH:mm:ss' );
125+ final format = DateFormat ('EEE, dd MMM yyyy HH:mm:ss' , 'en-US' );
126126 final isUtc = time.endsWith ('GMT' );
127127 return format.parse (time, isUtc);
128128}
129129
130130String toRfc7231Time (DateTime time) {
131- final format = DateFormat ('EEE, dd MMM yyyy HH:mm:ss' );
131+ final format = DateFormat ('EEE, dd MMM yyyy HH:mm:ss' , 'en-US' );
132132 final result = format.format (time);
133133 return time.isUtc ? '$result GMT' : result;
134134}
Original file line number Diff line number Diff line change 11import 'dart:typed_data' ;
22
3+ import 'package:intl/date_symbol_data_local.dart' ;
4+ import 'package:intl/intl.dart' ;
35import 'package:minio/src/utils.dart' ;
46import 'package:test/test.dart' ;
57
@@ -25,6 +27,20 @@ void testRfc7231Time() {
2527 expect (parseRfc7231Time (timeStringUtc), equals (timeUtc));
2628 expect (parseRfc7231Time (timeStringUtc).isUtc, isTrue);
2729 });
30+
31+ test (
32+ 'works for non en-US locale' , () async {
33+ initializeDateFormatting ('pt_BR' );
34+ Intl .withLocale (
35+ 'pt_BR' ,
36+ ()
37+ {
38+ expect (parseRfc7231Time (timeStringUtc), equals (timeUtc));
39+ expect (parseRfc7231Time (timeStringUtc).isUtc, isTrue);
40+ }
41+ );
42+ }
43+ );
2844 });
2945
3046 group ('toRfc7231Time' , () {
@@ -35,6 +51,19 @@ void testRfc7231Time() {
3551 test ('works for GMT time' , () {
3652 expect (toRfc7231Time (timeUtc), equals (timeStringUtc));
3753 });
54+
55+ test (
56+ 'works for non en-US locale' , () async {
57+ initializeDateFormatting ('pt_BR' );
58+ Intl .withLocale (
59+ 'pt_BR' ,
60+ ()
61+ {
62+ expect (toRfc7231Time (timeUtc), equals (timeStringUtc));
63+ }
64+ );
65+ }
66+ );
3867 });
3968}
4069
You can’t perform that action at this time.
0 commit comments