- 论坛徽章:
- 16
|
- #!/usr/local/bin/perl
- use strict;
- use Time::Local;
- use Time::Seconds;
- my @startTime=(2015,9,20,7);
- my $startSeconds=timelocal(0,0,0,$startTime[2],$startTime[1],$startTime[0]);
- my $startWeekday=Time::Seconds->new($startSeconds);
- my @person=('a','b','c','d');
- my $index = 0;
- while (<STDIN>) {
- chomp;
- my ($year,$month,$days)=split /:/;
- my $endSeconds=timelocal(0,0,0,$days,$month,$year);
- my $endWeekday = Time::Seconds->new($endSeconds);
- my $diffTime = $endWeekday - $startWeekday;
- if ($diffTime->days > (7 - $startTime[3])) {
- my $diffWeeks = int(($diffTime->days - (7 - $startTime[3]) + 6)/7);
- $index = ($diffWeeks) %($#person + 1);
- print "diffweek $diffWeeks \n";
- }
- print "person $person[$index]\n";
- }
复制代码 |
|