9
9
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
10
10
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
11
11
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
12
- # Copyright 2017, 2018, 2019, 2020, 2021, 2022 The Sympa Community. See the
13
- # AUTHORS.md file at the top-level directory of this distribution and at
14
- # <https://github.com/sympa-community/sympa.git>.
12
+ # Copyright 2017, 2018, 2019, 2020, 2021, 2022, 2023 The Sympa Community.
13
+ # See the AUTHORS.md file at the top-level directory of this distribution
14
+ # and at <https://github.com/sympa-community/sympa.git>.
15
15
#
16
16
# This program is free software; you can redistribute it and/or modify
17
17
# it under the terms of the GNU General Public License as published by
@@ -39,7 +39,6 @@ use IO::File qw();
39
39
use MIME::EncWords;
40
40
use MIME::Lite::HTML;
41
41
use POSIX qw();
42
- use Time::Local qw();
43
42
use URI;
44
43
use Data::Dumper; # tentative
45
44
@@ -4108,7 +4107,7 @@ sub do_my {
4108
4107
wwslog('info', '');
4109
4108
4110
4109
# Sets the date of the field "start date" to "today"
4111
- $param->{'d_day'} = POSIX::strftime('%d -%m-%Y ', localtime time);
4110
+ $param->{'d_day'} = POSIX::strftime('%Y -%m-%d ', localtime time);
4112
4111
_set_my_lists_info();
4113
4112
return 1;
4114
4113
}
@@ -8681,21 +8680,8 @@ sub do_latest_arc {
8681
8680
return 1;
8682
8681
}
8683
8682
8684
- sub get_timelocal_from_date {
8685
- my ($mday, $mon, $yr, $hr, $min, $sec, $zone) = @_;
8686
- my ($time) = 0;
8687
-
8688
- $yr -= 1900 if $yr >= 1900; # if given full 4 digit year
8689
- $yr += 100 if $yr <= 37; # in case of 2 digit years
8690
- if (($yr < 70) || ($yr > 137)) {
8691
- warn "Warning: Bad year (", $yr + 1900, ") using current\n";
8692
- $yr = (localtime(time))[5];
8693
- }
8694
-
8695
- $time = Time::Local::timelocal($sec, $min, $hr, $mday, $mon, $yr);
8696
- return $time;
8697
-
8698
- }
8683
+ # No longer used.
8684
+ #sub get_timelocal_from_date;
8699
8685
8700
8686
####################################################
8701
8687
# do_remove_arc
@@ -13755,7 +13741,7 @@ sub do_suspend_request {
13755
13741
wwslog('info', '');
13756
13742
13757
13743
## Sets the date of the field "start date" to "today"
13758
- $param->{'d_day'} = POSIX::strftime('%d -%m-%Y ', localtime time);
13744
+ $param->{'d_day'} = POSIX::strftime('%Y -%m-%d ', localtime time);
13759
13745
_set_my_lists_info();
13760
13746
13761
13747
# Compatibility with Sympa <= 6.1b.1.
@@ -13937,6 +13923,12 @@ sub do_suspend_request_action {
13937
13923
13938
13924
my $previous_action = $in{'previous_action'} || 'suspend_request';
13939
13925
13926
+ # Compat. <= 6.2.72
13927
+ $in{'date_deb'} =~ s/(\d\d)-(\d\d)-(\d\d\d\d)/$3-$2-$1/
13928
+ if $in{'date_deb'};
13929
+ $in{'date_fin'} =~ s/(\d\d)-(\d\d)-(\d\d\d\d)/$3-$2-$1/
13930
+ if $in{'date_fin'};
13931
+
13940
13932
if ($in{'sub_action'} eq 'suspendsave') {
13941
13933
13942
13934
# to retrieve the selected list
@@ -13961,59 +13953,23 @@ sub do_suspend_request_action {
13961
13953
return $previous_action;
13962
13954
}
13963
13955
13964
- if ($in{'date_deb'}) {
13965
- ($day1, $month1, $year1) = split(/\-/, $in{'date_deb'});
13966
- $month1 = $month1 - 1;
13967
-
13968
- if ( ($day1 =~ /([0-9]*)/)
13969
- && ($month1 =~ /([0-9]*)/)
13970
- && ($year1 =~ /([0-9]*)/)) {
13971
- if ( ((1 <= $day1) && ($day1 <= 31))
13972
- && ((0 <= $month1) && ($month1 <= 11))
13973
- && (1900 <= $year1)) {
13974
- ## Return an epoch date
13975
- $data->{'startdate'} =
13976
- Time::Local::timelocal(0, 0, 0, $day1, $month1,
13977
- $year1);
13978
- } else {
13979
- add_stash('user', 'missing_arg',
13980
- {argument => 'Start Date doesn\'t exist.'});
13981
- wwslog('info', 'Date doesn\'t exist');
13982
- return $previous_action;
13983
- }
13984
- } else {
13985
- add_stash('user', 'missing_arg',
13986
- {argument => 'Start Date doesn\'t exist.'});
13987
- wwslog('info', 'Date doesn\'t exist');
13988
- return $previous_action;
13989
- }
13990
- ## Case 1 : Start date & End date (without indefinite)
13991
- if (($in{'date_fin'}) && (!$in{'indefinite'})) {
13992
- ($day2, $month2, $year2) = split(/\-/, $in{'date_fin'});
13993
- $month2 = $month2 - 1;
13994
-
13995
- if ( ($day2 =~ /([0-9]*)/)
13996
- && ($month2 =~ /([0-9]*)/)
13997
- && ($year2 =~ /([0-9]*)/)) {
13998
- if ( ((1 <= $day2) && ($day2 <= 31))
13999
- && ((0 <= $month2) && ($month2 <= 11))
14000
- && (1900 <= $year2)) {
14001
- ## Return an epoch date
14002
- $data->{'enddate'} =
14003
- Time::Local::timelocal(0, 0, 0, $day2, $month2,
14004
- $year2);
14005
- } else {
14006
- add_stash('user', 'missing_arg',
14007
- {argument => 'End Date doesn\'t exist.'});
14008
- wwslog('info', 'Date doesn\'t exist');
14009
- return $previous_action;
14010
- }
14011
- } else {
14012
- add_stash('user', 'missing_arg',
14013
- {argument => 'End Date doesn\'t exist.'});
14014
- wwslog('info', 'Date doesn\'t exist');
14015
- return $previous_action;
14016
- }
13956
+ my $html_date_re = Sympa::Regexps::html_date();
13957
+ if (($in{'date_deb'} // '') =~ /\A$html_date_re\z/) {
13958
+ ($year1, $month1, $day1) = split /-/, $in{'date_deb'};
13959
+ # Return an epoch date
13960
+ $data->{'startdate'} =
13961
+ POSIX::mktime(0, 0, 0, $day1 + 0, $month1 - 1, $year1 - 1900);
13962
+
13963
+ if (($in{'date_fin'} // '') =~ /\A$html_date_re\z/
13964
+ and not $in{'indefinite'}) {
13965
+ # Case 1 : Start date & End date (without indefinite)
13966
+ ($year2, $month2, $day2) = split /-/, $in{'date_fin'};
13967
+ # Return an epoch date
13968
+ $data->{'enddate'} = POSIX::mktime(
13969
+ 0, 0, 0, $day2 + 0,
13970
+ $month2 - 1,
13971
+ $year2 - 1900
13972
+ );
14017
13973
14018
13974
unless ($data->{'startdate'} <= $data->{'enddate'}) {
14019
13975
add_stash(
@@ -14027,27 +13983,27 @@ sub do_suspend_request_action {
14027
13983
'The start date must be less than the end date.');
14028
13984
return $previous_action;
14029
13985
}
14030
- ## Case 2 : Start date & without indefinite (without end date)
14031
- } elsif ((!$in{'date_fin'}) && ($in{' indefinite'})) {
13986
+ } elsif ($in{'indefinite'}) {
13987
+ # Case 2 : Start date & without indefinite (without end date)
14032
13988
$data->{'enddate'} = undef;
14033
13989
} else {
14034
13990
add_stash(
14035
13991
'user',
14036
13992
'missing_arg',
14037
13993
{ argument =>
14038
- 'Choose end date (dd/mm/ yyyy) or indefinite end date'
13994
+ 'Choose end date (yyyy-mm-dd ) or indefinite end date'
14039
13995
}
14040
13996
);
14041
13997
wwslog('info',
14042
- 'Missing argument for the end date or syntax error : dd/mm/ yyyy or must choose a end date or indefinite end date'
13998
+ 'Missing argument for the end date or syntax error : yyyy-mm-dd or must choose a end date or indefinite end date'
14043
13999
);
14044
14000
return $previous_action;
14045
14001
}
14046
14002
} else {
14047
14003
add_stash('user', 'missing_arg',
14048
- {argument => 'Miss start date (dd/mm/ yyyy)'});
14004
+ {argument => 'Miss start date (yyyy-mm-dd )'});
14049
14005
wwslog('info',
14050
- 'Missing argument for the start date or syntax error : dd/mm/ yyyy'
14006
+ 'Missing argument for the start date or syntax error : yyyy-mm-dd '
14051
14007
);
14052
14008
return $previous_action;
14053
14009
}
@@ -15598,6 +15554,12 @@ sub do_viewlogs {
15598
15554
15599
15555
$param->{'total_results'} = 0;
15600
15556
15557
+ # Compat. <= 6.2.72
15558
+ $in{'date_from'} =~ s/(\d\d)-(\d\d)-(\d\d\d\d)/$3-$2-$1/
15559
+ if $in{'date_from'};
15560
+ $in{'date_to'} =~ s/(\d\d)-(\d\d)-(\d\d\d\d)/$3-$2-$1/
15561
+ if $in{'date_to'};
15562
+
15601
15563
my @dates = $log->get_log_date;
15602
15564
($param->{'date_from_formated'}, $param->{'date_to_formated'}) = @dates
15603
15565
if @dates;
0 commit comments