OpenMS
Loading...
Searching...
No Matches
Date Class Reference

Date Class. More...

#include <OpenMS/DATASTRUCTURES/Date.h>

Collaboration diagram for Date:
[legend]

Classes

struct  Fields
 

Public Member Functions

 Date ()
 Default constructor.
 
 Date (const Date &date)=default
 Copy constructor.
 
 Date (Date &&) noexcept=default
 Move constructor.
 
 ~Date ()=default
 Destructor.
 
Dateoperator= (const Date &source)=default
 Assignment operator.
 
Dateoperator= (Date &&) &noexcept=default
 Move assignment operator.
 
bool operator== (const Date &rhs) const
 Equality operator.
 
bool operator!= (const Date &rhs) const
 Inequality operator.
 
bool operator< (const Date &rhs) const
 Less than operator.
 
void set (const String &date)
 sets data from a string
 
void set (UInt month, UInt day, UInt year)
 sets data from three integers
 
String get () const
 Returns a string representation of the date.
 
void get (UInt &month, UInt &day, UInt &year) const
 Fills the arguments with the date.
 
void clear ()
 Sets the undefined date: 00/00/0000.
 
bool isValid () const
 Returns if the date is valid.
 
bool isNull () const
 Returns if the date is null.
 
int year () const
 Returns the year.
 
int month () const
 Returns the month.
 
int day () const
 Returns the day.
 

Static Public Member Functions

static Date today ()
 Returns the current date.
 

Private Attributes

struct OpenMS::Date::Fields fields_
 

Detailed Description

Date Class.

This class implements date handling. Import and export to/from both string and integers is possible.


Class Documentation

◆ OpenMS::Date::Fields

struct OpenMS::Date::Fields
Collaboration diagram for Date::Fields:
[legend]
Class Members
int day = 0
int month = 0
bool valid = false
int year = 0

Constructor & Destructor Documentation

◆ Date() [1/3]

Date ( )

Default constructor.

Fills the object with an undefined date: 00/00/0000

◆ Date() [2/3]

Date ( const Date date)
default

Copy constructor.

◆ Date() [3/3]

Date ( Date &&  )
defaultnoexcept

Move constructor.

◆ ~Date()

~Date ( )
default

Destructor.

Member Function Documentation

◆ clear()

void clear ( )

Sets the undefined date: 00/00/0000.

◆ day()

int day ( ) const

Returns the day.

◆ get() [1/2]

String get ( ) const

Returns a string representation of the date.

Uses the iso/ansi date format: 'yyyy-mm-dd'

◆ get() [2/2]

void get ( UInt month,
UInt day,
UInt year 
) const

Fills the arguments with the date.

Give the numbers in the following order: month, day and year.

◆ isNull()

bool isNull ( ) const

Returns if the date is null.

◆ isValid()

bool isValid ( ) const

Returns if the date is valid.

◆ month()

int month ( ) const

Returns the month.

◆ operator!=()

bool operator!= ( const Date rhs) const

Inequality operator.

◆ operator<()

bool operator< ( const Date rhs) const

Less than operator.

◆ operator=() [1/2]

Date & operator= ( const Date source)
default

Assignment operator.

◆ operator=() [2/2]

Date & operator= ( Date &&  ) &
defaultnoexcept

Move assignment operator.

◆ operator==()

bool operator== ( const Date rhs) const

Equality operator.

◆ set() [1/2]

void set ( const String date)

sets data from a string

The following date formats are supported:

  • mm/dd/yyyy
  • dd.mm.yyyy
  • yyyy-mm-dd
Exceptions
Exception::ParseErroris thrown if the date is given in the wrong format

◆ set() [2/2]

void set ( UInt  month,
UInt  day,
UInt  year 
)

sets data from three integers

Exceptions
Exception::ParseErroris thrown if an invalid date is given

◆ today()

static Date today ( )
static

Returns the current date.

◆ year()

int year ( ) const

Returns the year.

Member Data Documentation

◆ fields_

struct OpenMS::Date::Fields fields_
private