OpenMS  2.6.0
Public Member Functions | Static Public Member Functions | List of all members
DateTime Class Reference

DateTime Class. More...

#include <OpenMS/DATASTRUCTURES/DateTime.h>

Inheritance diagram for DateTime:
[legend]
Collaboration diagram for DateTime:
[legend]

Public Member Functions

 DateTime ()
 Default constructor. More...
 
 DateTime (const DateTime &date)
 Copy constructor. More...
 
 DateTime (const QDateTime &date)
 Copy constructor from Qt base class. More...
 
 DateTime (DateTime &&) noexcept
 Move constructor. More...
 
DateTimeoperator= (const DateTime &source)
 Assignment operator. More...
 
DateTimeoperator= (DateTime &&) &noexcept
 Move assignment operator. More...
 
void setDate (const String &date)
 sets date from a string More...
 
void setTime (const String &date)
 sets time from a string More...
 
void setDate (UInt month, UInt day, UInt year)
 sets data from three integers More...
 
void setTime (UInt hour, UInt minute, UInt second)
 sets time from three integers More...
 
void set (UInt month, UInt day, UInt year, UInt hour, UInt minute, UInt second)
 sets data from six integers More...
 
void get (UInt &month, UInt &day, UInt &year, UInt &hour, UInt &minute, UInt &second) const
 Fills the arguments with the date and the time. More...
 
void getDate (UInt &month, UInt &day, UInt &year) const
 Fills the arguments with the date. More...
 
String getDate () const
 Returns the date as string. More...
 
void getTime (UInt &hour, UInt &minute, UInt &second) const
 Fills the arguments with the time. More...
 
String getTime () const
 Returns the time as string. More...
 
void clear ()
 Sets the undefined date: 00/00/0000 00:00:00. More...
 
String get () const
 Returns a string representation of the date and time. More...
 
void set (const String &date)
 Sets date and time. More...
 

Static Public Member Functions

static DateTime now ()
 Returns the current date and time. More...
 

Detailed Description

DateTime Class.

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

Constructor & Destructor Documentation

◆ DateTime() [1/4]

DateTime ( )

Default constructor.

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

◆ DateTime() [2/4]

DateTime ( const DateTime date)

Copy constructor.

◆ DateTime() [3/4]

DateTime ( const QDateTime date)

Copy constructor from Qt base class.

◆ DateTime() [4/4]

DateTime ( DateTime &&  )
noexcept

Move constructor.

Member Function Documentation

◆ clear()

void clear ( )

Sets the undefined date: 00/00/0000 00:00:00.

◆ get() [1/2]

String get ( ) const

Returns a string representation of the date and time.

The format of the string will be yyyy-MM-dd hh:mm:ss

◆ get() [2/2]

void get ( UInt month,
UInt day,
UInt year,
UInt hour,
UInt minute,
UInt second 
) const

Fills the arguments with the date and the time.

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

◆ getDate() [1/2]

String getDate ( ) const

Returns the date as string.

The format of the string is yyyy-MM-dd

◆ getDate() [2/2]

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

Fills the arguments with the date.

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

◆ getTime() [1/2]

String getTime ( ) const

Returns the time as string.

The format of the string is hh:mm:ss

◆ getTime() [2/2]

void getTime ( UInt hour,
UInt minute,
UInt second 
) const

Fills the arguments with the time.

The arguments are all UInts and the order is hour minute second

Referenced by TOPPASBase::showLogMessage_(), and TOPPViewBase::showLogMessage_().

◆ now()

static DateTime now ( )
static

◆ operator=() [1/2]

DateTime& operator= ( const DateTime source)

Assignment operator.

◆ operator=() [2/2]

DateTime& operator= ( DateTime &&  ) &
noexcept

Move assignment operator.

◆ set() [1/2]

void set ( const String date)

Sets date and time.

The following formats are supported:

  • MM/dd/yyyy hh:mm:ss
  • dd.MM.yyyy hh:mm:ss
  • yyyy-MM-dd hh:mm:ss
  • yyyy-MM-ddThh:mm:ss (ISO 8601 format)
  • yyyy-MM-ddZ (ISO 8601 format)
  • yyyy-MM-dd+hh:mm (ISO 8601 format)
Exceptions
Exception::ParseError

◆ set() [2/2]

void set ( UInt  month,
UInt  day,
UInt  year,
UInt  hour,
UInt  minute,
UInt  second 
)

sets data from six integers

Give the numbers in the following order: month, day, year, hour, minute, second.

Exceptions
Exception::ParseError

Referenced by XMLHandler::asDateTime_(), and XMassFile::importExperimentalSettings().

◆ setDate() [1/2]

void setDate ( const String date)

sets date from a string

Reads both English, German and iso/ansi date formats: 'MM/dd/yyyy', 'dd.MM.yyyy' or 'yyyy-MM-dd'

Exceptions
Exception::ParseError

◆ setDate() [2/2]

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

sets data from three integers

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

Exceptions
Exception::ParseError

◆ setTime() [1/2]

void setTime ( const String date)

sets time from a string

Reads time format: 'hh:mm:ss'

Exceptions
Exception::ParseError

◆ setTime() [2/2]

void setTime ( UInt  hour,
UInt  minute,
UInt  second 
)

sets time from three integers

Give the numbers in the following order: hour, minute and second.

Exceptions
Exception::ParseError