Changeset 37068 for branches/eam_branches/ipp-ops-20130712/tools/czarcal
- Timestamp:
- Jul 17, 2014, 12:36:19 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-ops-20130712
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
tools/czarcal (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-ops-20130712
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-ops-20130712/tools/czarcal
r34894 r37068 16 16 my $start_date = shift; 17 17 my $num_assignments = shift; 18 19 18 $num_assignments = 1 unless $num_assignments; 20 19 20 my $num_events = 0; 21 21 22 22 # list of all czars 23 23 my @staff = qw( 24 bill 25 chris 24 26 mark 25 27 gene 26 bill27 28 heather 28 chris29 29 ); 30 30 31 die "usage: $0 <first czar> <start_date> <num assignments>\n czar list: @staff\n" 31 my @date_holidays = qw( 32 0101 33 0326 34 0611 35 0816 36 1225 37 ); 38 # MMNW 39 my @weekday_holidays = qw( 40 0131 41 0231 42 0541 43 0911 44 1121 45 1144 46 ); 47 48 49 50 die "usage: $0 <first czar> <start_date> [<num assignments>]\n czar list: @staff\n" 32 51 unless $start_date and $first_czar; 33 52 … … 48 67 49 68 50 51 69 my $year = substr $start_date, 0, 4; 52 70 my $month = substr $start_date, 4, 2; … … 62 80 for (my $i = 0; $i < $num_assignments; $i++) { 63 81 $tm = localtime($time); 64 if ($tm->wday != 6 and $tm->wday != 0) { 82 if ($tm->wday == 6 or $tm->wday == 0) { 83 # bump counter to account for weekend day 84 $num_assignments++; 85 } elsif (is_holiday($tm)) { 86 # bump counter to account for holiday 87 $num_assignments++; 88 } else { 65 89 66 90 assign_czar($this_czar, $tm->year+1900, $tm->mon+1, $tm->mday); … … 73 97 $j = 0; 74 98 } 75 } else {76 # bump counter to account for weekend day77 $num_assignments++;78 99 } 79 100 $time += 86400; 80 101 } 81 102 103 print "$end_vcalendar\n"; 82 104 83 print "$end_vcalendar\n";105 exit 0; 84 106 85 107 sub get_czars { … … 97 119 } 98 120 99 my $num_events = 0;100 121 sub assign_czar { 101 122 # print STDERR "assign: @_\n"; … … 132 153 } 133 154 155 sub is_holiday { 156 my $tm = shift; 134 157 158 my $slimdate = sprintf "%02d%02d", $tm->mon + 1, $tm->mday; 159 foreach my $d (@date_holidays) { 160 if ($d eq $slimdate) { 161 print STDERR "$d is a date holiday\n"; 162 return 1; 163 } 164 } 165 166 my $monthDayOfWeek = sprintf "%02d%d%d", $tm->mon + 1, 1 + ($tm->mday - $tm->wday) / 7, $tm->wday; 167 168 foreach my $d (@weekday_holidays) { 169 if ($d eq $monthDayOfWeek) { 170 print STDERR "$slimdate is a $d day of week holiday\n"; 171 return 1; 172 } 173 } 174 175 return 0; 176 } 177 178
Note:
See TracChangeset
for help on using the changeset viewer.
