| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/Utils.pm,v 1.45 2004/07/08 18:41:57 sh002i Exp $ |
4 | # $CVSHeader: webwork2/lib/WeBWorK/Utils.pm,v 1.46 2004/07/10 18:13:10 gage Exp $ |
| 5 | # |
5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
6 | # This program is free software; you can redistribute it and/or modify it under |
| 7 | # the terms of either: (a) the GNU General Public License as published by the |
7 | # the terms of either: (a) the GNU General Public License as published by the |
| 8 | # Free Software Foundation; either version 2, or (at your option) any later |
8 | # Free Software Foundation; either version 2, or (at your option) any later |
| 9 | # version, or (b) the "Artistic License" which comes with this package. |
9 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 39 | runtime_use |
39 | runtime_use |
| 40 | readFile |
40 | readFile |
| 41 | readDirectory |
41 | readDirectory |
| 42 | formatDateTime |
42 | formatDateTime |
| 43 | parseDateTime |
43 | parseDateTime |
|
|
44 | textDateTime |
|
|
45 | intDateTime |
| 44 | writeLog |
46 | writeLog |
| 45 | writeCourseLog |
47 | writeCourseLog |
| 46 | writeTimingLogEntry |
48 | writeTimingLogEntry |
| 47 | list2hash |
49 | list2hash |
| 48 | max |
50 | max |
| … | |
… | |
| 124 | sub parseDateTime($) { |
126 | sub parseDateTime($) { |
| 125 | my $string = shift; |
127 | my $string = shift; |
| 126 | # need to bring our string from "%m/%d/%y at %I:%M%P" to "%m/%d/%y %I:%M%P" format. |
128 | # need to bring our string from "%m/%d/%y at %I:%M%P" to "%m/%d/%y %I:%M%P" format. |
| 127 | $string =~ s/\bat\b/ /; |
129 | $string =~ s/\bat\b/ /; |
| 128 | return str2time($string); |
130 | return str2time($string); |
|
|
131 | } |
|
|
132 | |
|
|
133 | sub textDateTime($) { |
|
|
134 | return ($_[0] =~ m/^\d*$/) ? formatDateTime($_[0]) : $_[0]; |
|
|
135 | } |
|
|
136 | |
|
|
137 | sub intDateTime($) { |
|
|
138 | return ($_[0] =~ m/^\d*$/) ? $_[0] : parseDateTime($_[0]); |
| 129 | } |
139 | } |
| 130 | |
140 | |
| 131 | sub writeLog($$@) { |
141 | sub writeLog($$@) { |
| 132 | my ($ce, $facility, @message) = @_; |
142 | my ($ce, $facility, @message) = @_; |
| 133 | unless ($ce->{webworkFiles}->{logs}->{$facility}) { |
143 | unless ($ce->{webworkFiles}->{logs}->{$facility}) { |