OpenMS  2.5.0
Public Member Functions | Static Public Member Functions | List of all members
Date Class Reference

Date Class. More...

#include <OpenMS/DATASTRUCTURES/Date.h>

Inheritance diagram for Date:
QDate

Public Member Functions

 Date ()=default
 Default constructor. More...
 
 Date (const Date &date)=default
 Copy constructor. More...
 
 Date (const QDate &date)
 Copy constructor from Qt base class. More...
 
 Date (Date &&)=default
 Move constructor. More...
 
Dateoperator= (const Date &source)=default
 Assignment operator. More...
 
Dateoperator= (Date &&) &=default
 Move assignment operator. More...
 
void set (const String &date)
 sets data from a string More...
 
void set (UInt month, UInt day, UInt year)
 sets data from three integers More...
 
String get () const
 Returns a string representation of the date. More...
 
void get (UInt &month, UInt &day, UInt &year) const
 Fills the arguments with the date. More...
 
void clear ()
 Sets the undefined date: 00/00/0000. More...
 

Static Public Member Functions

static Date today ()
 Returns the current date. More...
 

Detailed Description

Date Class.

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

Constructor & Destructor Documentation

◆ Date() [1/4]

Date ( )
default

Default constructor.

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

◆ Date() [2/4]

Date ( const Date date)
default

Copy constructor.

◆ Date() [3/4]

Date ( const QDate date)

Copy constructor from Qt base class.

◆ Date() [4/4]

Date ( Date &&  )
default

Move constructor.

Member Function Documentation

◆ clear()

void clear ( )

Sets the undefined date: 00/00/0000.

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

◆ operator=() [1/2]

Date& operator= ( const Date source)
default

Assignment operator.

◆ operator=() [2/2]

Date& operator= ( Date &&  ) &
default

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