|
OPeNDAP Hyrax Back End Server (BES)
Updated for version 3.8.3
|
Helper class to parse in very simple string specifications of times and return it as an (approximate) duration in seconds. More...
#include <SimpleTimeParser.h>

Public Member Functions | |
| SimpleTimeParser () | |
| ~SimpleTimeParser () | |
Static Public Member Functions | |
| static bool | parseIntoSeconds (long &seconds, const std::string &duration) |
| Parse the string in duration and to calculate the (approximate) number of seconds it represents. More... | |
Helper class to parse in very simple string specifications of times and return it as an (approximate) duration in seconds.
By approximate, we use a month to be 31 days and a year to be 365 days for purposes of converting to seconds.
We only can parse strings of the form "%d %unit" where d stands for a number and unit stands for a single basic time unit in this list. We give the unit and then the strings that can be used to represent it.
seconds: { s, second, seconds } minutes: { m, min, mins } hours: { h, hour, hours } days: { day, days } weeks: { week, weeks} months: { month, months } [note: month considered 31 days!] years: { year, years }
For example:
"1 min" "3 s" "5 hours" "3 days" "10 seconds" "5 years" "1 month"
TODO This probably should be tested using CPPUnit
Definition at line 74 of file SimpleTimeParser.h.
| agg_util::SimpleTimeParser::SimpleTimeParser | ( | ) |
Definition at line 50 of file SimpleTimeParser.cc.
| agg_util::SimpleTimeParser::~SimpleTimeParser | ( | ) |
Definition at line 54 of file SimpleTimeParser.cc.
|
static |
Parse the string in duration and to calculate the (approximate) number of seconds it represents.
By approximate, we mean that a month is considered 31 days and a year as 365 days.
| seconds | the result will be placed in here on success |
| duration | time duration as specified in class docs. |
Definition at line 59 of file SimpleTimeParser.cc.
Referenced by ncml_module::ScanElement::getOlderThanAsSeconds().