Parent Directory
|
Revision Log
global: added some new hashes. learn how to use diff. CourseEnv: new uses WeBWorK::Utils WW: commented out a silly debugging function IO: fixed package name Translator: changed behavior of evaluate_modules and load_extra_packages: they now update the instance variable directly to avoid sharing modules that weren't asked for "this time". -sam
1 package WeBWorK::Utils; 2 use base qw(Exporter); 3 4 use strict; 5 use warnings; 6 use Date::Format; 7 use Date::Parse; 8 9 our @EXPORT = (); 10 our @EXPORT_OK = qw(runtime_use readFile formatDate); 11 12 sub runtime_use($) { 13 return unless @_; 14 eval "require $_[0]; import $_[0]"; 15 die $@ if $@; 16 } 17 18 sub readFile($) { 19 my $fileName = shift; 20 open INPUTFILE, "<", $fileName 21 or die "Failed to read $fileName: $!"; 22 local $/ = undef; 23 my $result = <INPUTFILE>; 24 close INPUTFILE; 25 return $result; 26 } 27 28 sub formatDateTime($) { 29 my $dateTime = shift; 30 # "standard" WeBWorK date/time format: 31 # %m month number, starting with 01 32 # %d numeric day of the month, with leading zeros (eg 01..31) 33 # %y year (2 digits) 34 # %I hour, 12 hour clock, leading 0's) 35 # %M minute, leading 0's 36 # %P am or pm (Yes %p and %P are backwards :) 37 return time2str "%m/%d/%y %I:%M%P", $dateTime; 38 } 39 40 sub parseDateTime($) { 41 $string = shift; 42 return str2time $string; 43 }
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |