MeteoIODoc 20250425.c00b4cff
mio::DateRange Class Reference

Detailed Description

A class to represent and handle date ranges. They can be sorted, checked for uniqueness and a date can be compared to the range (is it before or after?).

Author
Mathias Bavay

#include <Date.h>

Public Member Functions

 DateRange ()
 
 DateRange (const Date &d1, const Date &d2)
 
 DateRange (const std::string &range_spec, const double &tz)
 
void setRange (const std::string &range_spec, const double &tz)
 Set the date range from a provided date range string (at most daily resolution) More...
 
bool isUndef () const
 
bool in (const Date &a) const
 Is the provided date within the current range? More...
 
bool hasOverlap (const Date &i_start, const Date &i_end) const
 Is the provided date range within the current range? More...
 
bool operator< (const Date &a) const
 Is the range before the provided date? More...
 
bool operator> (const Date &a) const
 Is the range after the provided date? More...
 
bool operator< (const DateRange &a) const
 
bool operator== (const DateRange &a) const
 
const std::string toString () const
 

Public Attributes

Date start
 
Date end
 

Constructor & Destructor Documentation

◆ DateRange() [1/3]

mio::DateRange::DateRange ( )
inline

◆ DateRange() [2/3]

mio::DateRange::DateRange ( const Date d1,
const Date d2 
)
inline

◆ DateRange() [3/3]

mio::DateRange::DateRange ( const std::string &  range_spec,
const double &  tz 
)
inline

Member Function Documentation

◆ hasOverlap()

bool mio::DateRange::hasOverlap ( const Date i_start,
const Date i_end 
) const

Is the provided date range within the current range?

Parameters
[in]i_startstart of the range to check
[in]i_endend of the range to check
Returns
true if both ranges have some overlap, false otherwise

◆ in()

bool mio::DateRange::in ( const Date a) const
inline

Is the provided date within the current range?

Parameters
[in]aDate to check
Returns
true if the date is within the current range, false otherwise

◆ isUndef()

bool mio::DateRange::isUndef ( ) const
inline

◆ operator<() [1/2]

bool mio::DateRange::operator< ( const Date a) const
inline

Is the range before the provided date?

Parameters
[in]aDate to check
Returns
true if the date is more than the end of the current range, false otherwise

◆ operator<() [2/2]

bool mio::DateRange::operator< ( const DateRange a) const
inline

◆ operator==()

bool mio::DateRange::operator== ( const DateRange a) const
inline

◆ operator>()

bool mio::DateRange::operator> ( const Date a) const
inline

Is the range after the provided date?

Parameters
[in]aDate to check
Returns
true if the date is less than the start of the current range, false otherwise

◆ setRange()

void mio::DateRange::setRange ( const std::string &  range_spec,
const double &  tz 
)

Set the date range from a provided date range string (at most daily resolution)

Such a string can either contain only one date (at least the year must be provided, everything else is optional) or two dates separated by a dash. Examples of valid ranges:

  • 2024 - 2025 (this means from 2024-01-01 until 2025-12-31 at midnight)
  • 2024-10 (this means the whole month of October 2024)
  • 2024-10 - 2025 (this means from 2024-10-01 until 2025-12-31)
Parameters
[in]range_specthe range string
[in]tztimezone of the dates provided in range_spec

◆ toString()

const std::string mio::DateRange::toString ( ) const
inline

Member Data Documentation

◆ end

Date mio::DateRange::end

◆ start

Date mio::DateRange::start

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