OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
agg_util::SimpleTimeParser Class Reference

Helper class to parse in very simple string specifications of times and return it as an (approximate) duration in seconds. More...

#include <SimpleTimeParser.h>

Collaboration diagram for agg_util::SimpleTimeParser:
Collaboration graph

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

agg_util::SimpleTimeParser::SimpleTimeParser ( )

Definition at line 50 of file SimpleTimeParser.cc.

agg_util::SimpleTimeParser::~SimpleTimeParser ( )

Definition at line 54 of file SimpleTimeParser.cc.

Member Function Documentation

bool agg_util::SimpleTimeParser::parseIntoSeconds ( long &  seconds,
const std::string &  duration 
)
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.

Parameters
secondsthe result will be placed in here on success
durationtime duration as specified in class docs.
Returns
whether the parse was successful. if true, seconds is valid. if false, seconds will also be -1.

Definition at line 59 of file SimpleTimeParser.cc.

Referenced by ncml_module::ScanElement::getOlderThanAsSeconds().


The documentation for this class was generated from the following files: