Skip to content

Commit 0edead5

Browse files
committed
add set_locale() method; adjust docs and tests
1 parent b2febed commit 0edead5

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

Changes

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Changes for DateTime::Set
22

3+
dev 2020-10-10
4+
- add set_locale(), following the DateTime API
5+
Adjusted t/15time_zone.t and docs.
6+
37
0.3900 2016-10-09
48
- require Params::Validate
59

lib/DateTime/Set.pm

+20-2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,17 @@ sub set_time_zone {
170170
$self;
171171
}
172172

173+
sub set_locale {
174+
my ($self, $locale) = @_;
175+
$self->{set} = $self->{set}->iterate(
176+
sub {
177+
my $min = $_[0]->min;
178+
$min->clone->set_locale( $locale ) if ref($min);
179+
},
180+
);
181+
$self;
182+
}
183+
173184
sub set {
174185
my $self = shift;
175186
my %args = validate( @_,
@@ -901,10 +912,17 @@ method.
901912
This method will attempt to apply the C<set_time_zone> method to every
902913
datetime in the set.
903914
904-
=item * set( locale => .. )
915+
=item * set_locale( $locale )
916+
917+
This method will attempt to apply the C<set_locale> method to every
918+
datetime in the set.
905919
906-
This method can be used to change the C<locale> of a datetime set.
920+
=item * set( minute => 0, second => 0 )
907921
922+
This method can be used to change the local components of a date time set. This
923+
method accepts any parameter allowed by the C<< DateTime->new() >> method except for
924+
"locale" or "time_zone". Use C<set_locale()> and C<set_time_zone()> for those
925+
instead.
908926
909927
=item * start, min
910928

t/15time_zone.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ is ( $months->clone->add( days => 1 )->
130130
'default locale' );
131131

132132
is ( $months->clone->add( days => 1 )->
133-
set( locale => 'en_US' )->
133+
set_locale( 'en_US' )->
134134
next( $t1 )->
135135
strftime( "%a" ),
136136
'Sun',

0 commit comments

Comments
 (0)