WeBWorK::Utils - useful utilities used by other WeBWorK modules.
Creates a directory with the given name, permission bits, and group ID.
Traverses the directory tree rooted at $dir, returning a list of files, named pipes, and sockets matching the regular expression $match_qr. Directories matching the regular expression $prune_qr are not visited.
$match_full and $prune_full are boolean values that indicate whether $match_qr and $prune_qr, respectively, should be applied to the bare directory entry (false) or to the path to the directory entry relative to $dir.
@matches is a list of paths relative to $dir.
Ensures that $path refers to a location "inside" $dir. If $allow_relative is true and $path is not absoulte, it is assumed to be relative to $dir.
The method of checking is rather rudimentary at the moment. First, upreferences ("..") are disallowed, in $path, then it is checked to make sure that some prefix of it matches $dir.
If either of these checks fails, a false value is returned. Otherwise, a true value is returned.
Parses $string as a datetime. If $display_tz is given, $string is assumed to be in that timezone. Otherwise, the server's timezone is used. The result, $dateTime, is an integer UNIX datetime (epoch) in the server's timezone.
Formats the UNIX datetime $dateTime in the custom format provided by $format_string. If $format_string is not provided, the standard WeBWorK datetime format is used. $dateTime is assumed to be in the server's time zone. If $display_tz is given, the datetime is converted from the server's timezone to the timezone specified. If $format_string is a method of the $dt->locale instance, then format_cldr is used, and otherwise strftime is used. The available patterns for $format_string can be found in the documentation for the perl DateTime package under the heading of strftime Patterns. The available methods for the $dt->locale instance are documented at https://metacpan.org/pod/DateTime::Locale::FromData. $dateTime is assumed to be in the server's time zone. If $display_tz is given, the datetime is converted from the server's timezone to the timezone specified. If $locale is provided, the string returned will be in the format of that locale, which is useful for automatically translating things like days of the week and month names. If $locale is not provided, perl defaults to en_US.
Accepts a UNIX datetime or a formatted string, returns a formatted string.
Accepts a UNIX datetime or a formatted string, returns a UNIX datetime.
If $display_tz is not a legal time zone then replace it with America/New_York and issue warning.
Makes a stab at converting a time (with a possible unit) into a number of seconds.
True if $now is less than $time. If $now is not specified, the value of time() is used.
True if $now is greater than $time. If $now is not specified, the value of time() is used.
True if $now is greater than or equal to $start and less than or equal to $end. If $now is not specified, the value of time() is used.