DCMTK Version 3.7.0 OFFIS DICOM Toolkit

Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Attributes | Friends | List of all members
OFDate Class Reference

This class provides a collection of date functions. More...

## Public Member Functions
| OFDate ()
| default constructor. More...
| OFDate (const OFDate &dateVal)
| copy constructor More...
| OFDate (const unsigned int year, const unsigned int month, const unsigned int day)
| constructor with init values More...
virtual | ~OFDate ()
| destructor
virtual OFDate & | operator= (const OFDate &dateVal)
| assignment operator More...
virtual OFBool | operator== (const OFDate &dateVal) const
| comparison operator (equal) More...
virtual OFBool | operator!= (const OFDate &dateVal) const
| comparison operator (unequal) More...
virtual OFBool | operator< (const OFDate &dateVal) const
| comparison operator (less than) More...
virtual OFBool | operator<= (const OFDate &dateVal) const
| comparison operator (less than or equal) More...
virtual OFBool | operator>= (const OFDate &dateVal) const
| comparison operator (greater than or equal) More...
virtual OFBool | operator> (const OFDate &dateVal) const
| comparison operator (greater than) More...
virtual void | clear ()
| reset the date value. More...
virtual OFBool | isValid () const
| check whether the currently stored date value is valid. More...
OFBool | setDate (const unsigned int year, const unsigned int month, const unsigned int day)
| set the date value to the specified date. More...
OFBool | setYear (const unsigned int year)
| set the date value to the specified year. More...
OFBool | setMonth (const unsigned int month)
| set the date value to the specified month. More...
OFBool | setDay (const unsigned int day)
| set the date value to the specified day. More...
OFBool | setCurrentDate ()
| set the date value to the current system date. More...
OFBool | setISOFormattedDate (const OFString &formattedDate)
| set the date value to the given ISO formatted date string. More...
unsigned int | getYear () const
| get the currently stored year value More...
unsigned int | getMonth () const
| get the currently stored month value More...
unsigned int | getDay () const
| get the currently stored day value More...
OFBool | getISOFormattedDate (OFString &formattedDate, const OFBool showDelimiter=OFTrue) const
| get the current date value in ISO format. More...

## Static Public Member Functions
static OFDate | getCurrentDate ()
| get the current system date More...

## Protected Member Functions
OFBool | setCurrentDate (const time_t &tt)
| set the date value to the current system date. More...

## Static Protected Member Functions
static OFBool | isDateValid (const unsigned int year, const unsigned int month, const unsigned int day)
| check whether the given date is valid. More...

## Private Attributes
unsigned int | Year
| currently stored year value
unsigned int | Month
| currently stored month value
unsigned int | Day
| currently stored day value

## Friends
class | OFDateTime
| allow class OFDateTime to access protected class members

## Detailed Description

This class provides a collection of date functions.

## Constructor & Destructor Documentation

## ◆ OFDate() [1/3]

OFDate::OFDate | ( |  | ) |

default constructor.

Initializes Year, Month and Day to 0.

## ◆ OFDate() [2/3]

OFDate::OFDate | ( | const OFDate & | dateVal | ) |

copy constructor

Parameters

  dateVal | date object to be copied

## ◆ OFDate() [3/3]

OFDate::OFDate | ( | const unsigned int | year,
|  | const unsigned int | month,
|  | const unsigned int | day
| ) |  |

constructor with init values

Parameters

  year | year value to be set
  month | month value to be set
  day | day value to be set

## Member Function Documentation

## ◆ clear()

virtual void OFDate::clear | ( |  | ) |
| virtual

reset the date value.

Sets the year, month and day to "0". NB: Date becomes invalid.

## ◆ getCurrentDate()

static OFDate OFDate::getCurrentDate | ( |  | ) |
| static

get the current system date

Returns
  date object with the current system date set

## ◆ getDay()

unsigned int OFDate::getDay | ( |  | ) | const

get the currently stored day value

Returns
  day value (might be invalid, i.e. out of range)

## ◆ getISOFormattedDate()

OFBool OFDate::getISOFormattedDate | ( | OFString & | formattedDate,
|  | const OFBool | showDelimiter = `OFTrue`
| ) |  | const

get the current date value in ISO format.

The two ISO date formats supported by this function are "YYYY-MM-DD" (with delimiters) and "YYYYMMDD" (without delimiters, useful for DICOM date type).

Parameters

  formattedDate | reference to string variable where the result is stored
  showDelimiter | flag, indicating whether to use delimiters ("-") or not

Returns
  OFTrue if result variable has been set, OFFalse otherwise

Referenced by DcmIODUtil::setContentDateAndTimeNow().

## ◆ getMonth()

unsigned int OFDate::getMonth | ( |  | ) | const

get the currently stored month value

Returns
  month value (might be invalid, i.e. out of range)

## ◆ getYear()

unsigned int OFDate::getYear | ( |  | ) | const

get the currently stored year value

Returns
  year value (might be invalid, i.e. out of range)

## ◆ isDateValid()

static OFBool OFDate::isDateValid | ( | const unsigned int | year,
|  | const unsigned int | month,
|  | const unsigned int | day
| ) |  |
| static protected

check whether the given date is valid.

Currently, this method only checks whether the month is within the range of 1 to 12 and the day is within the range of 1 to 31. In the future this routine might be enhanced.

Parameters

  year | year value to be checked
  month | month value to be checked
  day | day value to be checked

Returns
  OFTrue if the current value is valid, OFFalse otherwise

## ◆ isValid()

virtual OFBool OFDate::isValid | ( |  | ) | const
| virtual

check whether the currently stored date value is valid.

Currently, this method only checks whether the month is within the range of 1 to 12 and the day is within the range of 1 to 31. In the future this routine might be enhanced.

Returns
  OFTrue if the current value is valid, OFFalse otherwise

## ◆ operator!=()

virtual OFBool OFDate::operator!= | ( | const OFDate & | dateVal | ) | const
| virtual

comparison operator (unequal)

Parameters

  dateVal | date value compared with the current value

Returns
  OFTrue if given date is unequal, OFFalse otherwise

## ◆ operator<()

virtual OFBool OFDate::operator< | ( | const OFDate & | dateVal | ) | const
| virtual

comparison operator (less than)

Parameters

  dateVal | date value compared with the current value

Returns
  OFTrue if current date is earlier than the given value, OFFalse otherwise

## ◆ operator<=()

virtual OFBool OFDate::operator<= | ( | const OFDate & | dateVal | ) | const
| virtual

comparison operator (less than or equal)

Parameters

  dateVal | date value compared with the current value

Returns
  OFTrue if current date is earlier than or identical to the given value, OFFalse otherwise

## ◆ operator=()

virtual OFDate& OFDate::operator= | ( | const OFDate & | dateVal | ) |
| virtual

assignment operator

Parameters

  dateVal | date value to be set

Returns
  reference to this object (with new value)

## ◆ operator==()

virtual OFBool OFDate::operator== | ( | const OFDate & | dateVal | ) | const
| virtual

comparison operator (equal)

Parameters

  dateVal | date value compared with the current value

Returns
  OFTrue if given date is equal, OFFalse otherwise

## ◆ operator>()

virtual OFBool OFDate::operator> | ( | const OFDate & | dateVal | ) | const
| virtual

comparison operator (greater than)

Parameters

  dateVal | date value compared with the current value

Returns
  OFTrue if current date is later than the given value, OFFalse otherwise

## ◆ operator>=()

virtual OFBool OFDate::operator>= | ( | const OFDate & | dateVal | ) | const
| virtual

comparison operator (greater than or equal)

Parameters

  dateVal | date value compared with the current value

Returns
  OFTrue if current date is later than or identical to the given value, OFFalse otherwise

## ◆ setCurrentDate() [1/2]

OFBool OFDate::setCurrentDate | ( |  | ) |

set the date value to the current system date.

This function uses operating system dependent routines. If they are unavailable for some reason the current value is not modified.

Returns
  OFTrue if the current system date has been set, OFFalse otherwise

Referenced by DcmIODUtil::setContentDateAndTimeNow().

## ◆ setCurrentDate() [2/2]

OFBool OFDate::setCurrentDate | ( | const time_t & | tt | ) |
| protected

set the date value to the current system date.

This function uses operating system dependent routines. If they are unavailable for some reason the current value is not modified.

Parameters

  tt | current system time (as returned by the time() function )

Returns
  OFTrue if the current system date has been set, OFFalse otherwise

## ◆ setDate()

OFBool OFDate::setDate | ( | const unsigned int | year,
|  | const unsigned int | month,
|  | const unsigned int | day
| ) |  |

set the date value to the specified date.

Before the new value is set it is checked using the "isValid()" routine.

Parameters

  year | new year value to be set
  month | new month value to be set
  day | new day value to be set

Returns
  OFTrue if the new value is valid and has been set, OFFalse otherwise

## ◆ setDay()

OFBool OFDate::setDay | ( | const unsigned int | day | ) |

set the date value to the specified day.

Before the new value is set it is checked using the "isValid()" routine.

Parameters

  day | new day value to be set

Returns
  OFTrue if the new value is valid and has been set, OFFalse otherwise

## ◆ setISOFormattedDate()

OFBool OFDate::setISOFormattedDate | ( | const OFString & | formattedDate | ) |

set the date value to the given ISO formatted date string.

The two ISO date formats supported by this function are "YYYY-MM-DD" (with arbitrary delimiters) and "YYYYMMDD" (without delimiters, useful for DICOM date type).

Parameters

  formattedDate | ISO formatted date value to be set

Returns
  OFTrue if input is valid and result variable has been set, OFFalse otherwise

## ◆ setMonth()

OFBool OFDate::setMonth | ( | const unsigned int | month | ) |

set the date value to the specified month.

Before the new value is set it is checked using the "isValid()" routine.

Parameters

  month | new month value to be set

Returns
  OFTrue if the new value is valid and has been set, OFFalse otherwise

## ◆ setYear()

OFBool OFDate::setYear | ( | const unsigned int | year | ) |

set the date value to the specified year.

Before the new value is set it is checked using the "isValid()" routine.

Parameters

  year | new year value to be set

Returns
  OFTrue if the new value is valid and has been set, OFFalse otherwise

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

- ofstd/include/dcmtk/ofstd/ofdate.h

Generated on Mon Dec 15 2025 for DCMTK Version 3.7.0 by Doxygen 1.9.1