HTTP::WebTest::Plugin::DateTest - Evaluate the "age" of embedded date strings in response body
Version 1.01 - $Revision: 1.8 $
Compatible with HTTP::WebTest 2.x API
Not Applicable - see HTTP::WEBTEST
This plugin provides a test for the age of a date string inside the response body. It supports anything Date::Parse can parse. There is limited support for other locales for which a Date::Language::* module exist. The Date::Languge and Date::Parse modules are part of the TimeDate distribution, available from a CPAN near you.
Date::Parse
Date::Language::*
Date::Languge
TimeDate
NOTE: The following parameters date_start, date_end and date_maxage are lists, so they should be specified in order for multiple date tests.
date_start
date_end
date_maxage
Text string which marks the start of a date string in the returned page. The date string should look like anything that Date::Parse is able to understand. Leading/trailing whitespace is no problem
Text string which marks the end of a date string in the returned page. The date string should look like anything that Date::Parse is able to understand. Leading/trailing whitespace is no problem
Maximum age of the parsed date string in seconds. This is evaluated against the current time at runtime.
Format: N [units]
where N is a (floating point-) number, followed by one of these unit specifiers (case insensitive):
N
s(econds) - default m(inutes) h(ours) d(ays) w(eeks)
The default is seconds. Only the first character is relevant, any leading text is ignored. An unknown unit specifier defaults to seconds.
Global parameter for all date tests.
Specify the language in which the date string is written. Locales are taken from Date::Language::(Locale) modules (part of Date::Parse). The value of date_locale is normalized to Capitalized notation, so this parameter is not case sensitive.
Date::Language::(Locale)
date_locale
WARNING: this works by literally translating the date string components to their English names. This fails if the notational conventions are very different (order of day, month, year etc.)
There are languages where abbreviated day- and month names are the same, notably Mardi and Mars in French, and Maandag and Maart in Dutch.
To work around the resulting ambiguity, all non-numerical components are stripped from the left side of the date string. This works for the common case where a weekday starts the string, but doesn't in some other cases.
Example (this will work):
date_locale = 'French' "Mar 19 Mars 2002, 17:25" => "19 Mars 2002, 17:25" => "19 Mar 2002, 17:25"
Example (this will fail for languages other than English):
"Mar 19, 2002 17:25" => "19, 2002 17:25" => (not parsable)
Note: the last notation is very uncommon in Dutch, so this assumption is generally no problem for this locale. YMMV!
Copyright (c) 2002,2003 Johannes la Poutre. All rights reserved.
This module is free software. It may be used, redistributed and/or modified under the terms of the Perl Artistic License.
HTTP::WebTest
HTTP::WebTest::API
HTTP::WebTest::Plugin
HTTP::WebTest::Plugins
To install HTTP::WebTest::Plugin::DateTest, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::WebTest::Plugin::DateTest
CPAN shell
perl -MCPAN -e shell install HTTP::WebTest::Plugin::DateTest
For more information on module installation, please visit the detailed CPAN module installation guide.