📄 oftime.h
字号:
/* * * Copyright (C) 2002-2005, OFFIS * * This software and supporting documentation were developed by * * Kuratorium OFFIS e.V. * Healthcare Information and Communication Systems * Escherweg 2 * D-26121 Oldenburg, Germany * * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. * * Module: ofstd * * Author: Joerg Riesmeier * * Purpose: Class for time functions * * Last Update: $Author: meichel $ * Update Date: $Date: 2005/12/08 16:06:09 $ * CVS/RCS Revision: $Revision: 1.8 $ * Status: $State: Exp $ * * CVS/RCS Log at end of file * */#ifndef OFTIME_H#define OFTIME_H#include "dcmtk/config/osconfig.h"BEGIN_EXTERN_C#ifdef HAVE_SYS_TYPES_H# include <sys/types.h> /* for struct time_t */#endifEND_EXTERN_C#include "dcmtk/ofstd/ofstring.h" /* for class OFString *//*---------------------* * class declaration * *---------------------*//** This class provides a collection of time functions */class OFTime{ // allow class OFDateTime to access protected class members friend class OFDateTime; public: /** default constructor. * Initializes Hour, Minute, Second and TimeZone to 0. */ OFTime(); /** copy constructor * @param timeVal time object to be copied */ OFTime(const OFTime &timeVal); /** constructor with init values * @param hour hour value to be set * @param minute minute value to be set * @param second second value to be set (incl. fraction of seconds) * @param timeZone optional offset to Coordinated Universal Time (UTC) in hours */ OFTime(const unsigned int hour, const unsigned int minute, const double second, const double timeZone = 0); /** destructor */ virtual ~OFTime(); /** assignment operator * @param timeVal time value to be set * @return reference to this object (with new value) */ virtual OFTime &operator=(const OFTime &timeVal); /** comparison operator (equal). * Please note that the time values are first transformed to the Coordinated Universal * Time (UTC) before they are compared. * @param timeVal time value compared with the current value * @return OFTrue if given time is equal, OFFalse otherwise */ virtual OFBool operator==(const OFTime &timeVal) const; /** comparison operator (unequal) * Please note that the time values are first transformed to the Coordinated Universal * Time (UTC) before they are compared. * @param timeVal time value compared with the current value * @return OFTrue if given time is unequal, OFFalse otherwise */ virtual OFBool operator!=(const OFTime &timeVal) const; /** comparison operator (less than) * Please note that the time values are first transformed to the Coordinated Universal * Time (UTC) before they are compared. * @param timeVal time value compared with the current value * @return OFTrue if current time is earlier than the given value, OFFalse otherwise */ virtual OFBool operator<(const OFTime &timeVal) const; /** comparison operator (less than or equal) * Please note that the time values are first transformed to the Coordinated Universal * Time (UTC) before they are compared. * @param timeVal time value compared with the current value * @return OFTrue if current time is earlier than or identical to the given value, * OFFalse otherwise */ virtual OFBool operator<=(const OFTime &timeVal) const; /** comparison operator (greater than or equal) * Please note that the time values are first transformed to the Coordinated Universal * Time (UTC) before they are compared. * @param timeVal time value compared with the current value * @return OFTrue if current time is later than or identical to the given value, * OFFalse otherwise */ virtual OFBool operator>=(const OFTime &timeVal) const; /** comparison operator (greater than) * Please note that the time values are first transformed to the Coordinated Universal * Time (UTC) before they are compared. * @param timeVal time value compared with the current value * @return OFTrue if current time is later than the given value, OFFalse otherwise */ virtual OFBool operator>(const OFTime &timeVal) const; /** reset the time value. * Sets the hour, minute, second and time zone to "0". */ virtual void clear(); /** check whether the currently stored time value is valid. * Valid ranges: [0,24[ for 'hour', [0,60[ for 'minute', [0.0,60.0[ for 'second' * and [-12.0,+12.0] for 'timeZone' * @return OFTrue if the current value is valid, OFFalse otherwise */ virtual OFBool isValid() const; /** set the time value to the specified time. * Before the new value is set it is checked using the "isValid()" routine. * @param hour new hour value to be set * @param minute new minute value to be set * @param second new second value to be set (incl. fraction of seconds) * @param timeZone optional offset to Coordinated Universal Time (UTC) in hours * @return OFTrue if the new value is valid and has been set, OFFalse otherwise */ OFBool setTime(const unsigned int hour, const unsigned int minute, const double second, const double timeZone = 0); /** set the time value to the specified hour. * Before the new value is set it is checked using the "isValid()" routine. * @param hour new hour value to be set * @return OFTrue if the new value is valid and has been set, OFFalse otherwise */ OFBool setHour(const unsigned int hour); /** set the time value to the specified minute. * Before the new value is set it is checked using the "isValid()" routine. * @param minute new minute value to be set * @return OFTrue if the new value is valid and has been set, OFFalse otherwise */ OFBool setMinute(const unsigned int minute); /** set the time value to the specified second. * Before the new value is set it is checked using the "isValid()" routine. * @param second new second value to be set (incl. fraction of seconds) * @return OFTrue if the new value is valid and has been set, OFFalse otherwise */ OFBool setSecond(const double second); /** set the time zone to the specified value. * The time zone is given as the offset (in hours) to the Coordinated Universal * Time (UTC). Valid values are for instance "+1.0" (plus one hour) and "-2.5" * (minus two and a half hour, i.e. 2 hours and 30 minutes). Before the new value * is set it is checked using the "isValid()" routine. * @param timeZone new timeZone value to be set * @return OFTrue if the new value is valid and has been set, OFFalse otherwise */ OFBool setTimeZone(const double timeZone); /** set the time zone to the specified value. * The time zone is given as the offset (in hours and minutes) to the Coordinated * Universal Time (UTC). Before the new value is set it is checked using the * "isValid()" routine. * @param hour new hour value to be set for the time zone * @param minute new minute value to be set for the time zone * @return OFTrue if the new value is valid and has been set, OFFalse otherwise */ OFBool setTimeZone(const signed int hour, const unsigned int minute); /** set the time to the specified number of seconds * @param seconds number of seconds since "00:00:00" specifying time to set * @param timeZone optional offset to Coordinated Universal Time (UTC) in hours * @param normalize if OFTrue the 'seconds' value is normalized to the valid range * [0.0,86400.0[ otherwise the value is checked as is * @return OFTrue if the new value is valid and has been set, OFFalse otherwise */ OFBool setTimeInSeconds(const double seconds, const double timeZone = 0, const OFBool normalize = OFTrue); /** set the time to the specified number of hours * @param hours number of hours since "00:00:00" specifying time to set * @param timeZone optional offset to Coordinated Universal Time (UTC) in hours * @param normalize if OFTrue the 'hours' value is normalized to the valid range * [0.0,24.0[ otherwise the value is checked as is * @return OFTrue if the new value is valid and has been set, OFFalse otherwise */ OFBool setTimeInHours(const double hours, const double timeZone = 0, const OFBool normalize = OFTrue); /** set the time value to the current system time. * This function uses operating system dependent routines. If they are unavailable * for some reason the current value is not modified. * @return OFTrue if the current system time has been set, OFFalse otherwise */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -