datetime.h
来自「这是VCF框架的代码」· C头文件 代码 · 共 1,106 行 · 第 1/2 页
H
1,106 行
@see incrMonth() @return the object itself */ DateTime& decrMonth(const unsigned long& by=1); /** decrements the day of this date object @param unsigned long the amount to decrement the day by @return the object itself */ DateTime& decrDay(const unsigned long& by=1); /** decrements the hour of this date object @param unsigned long the amount to decrement the hour by @return the object itself */ DateTime& decrHour(const unsigned long& by=1); /** decrements the minute of this date object @param unsigned long the amount to decrement the minute by @return the object itself */ DateTime& decrMinute(const unsigned long& by=1); /** decrements the second of this date object @param unsigned long the amount to decrement the second by @return the object itself */ DateTime& decrSecond(const unsigned long& by=1); /** decrements the millisecond of this date object @param unsigned long the amount to decrement the millisecond by @return the object itself */ DateTime& decrMilliSecond(const unsigned long& by=1); /** templatized class for iterating a date, either forward or backard in time, where the template type DateLogic is a class with the following static methods: \code class SomeDateLogic { public: static void incr( DateTime& dt, unsigned long offset ); static void decr( DateTime& dt, unsigned long offset ); }; \endcode */ template <typename DateLogic> class Iterator #if defined(VCF_BCC) || defined(__INTEL_COMPILER) || defined(VCF_CW) || defined(VCF_MINGW) || defined(VCF_GCC) ; #else { public: Iterator() { } Iterator( const DateTime& dt ) : dt_(dt){ } Iterator& operator=( const DateTime& dt ) { dt_ = dt; return *this; } DateTime& operator* () { return dt_; } bool operator==( const Iterator& rhs ) const { return dt_ == rhs.dt_; } bool operator!=( const Iterator& rhs ) const { return dt_ != rhs.dt_; } Iterator& operator++() { // prefix DateLogic::incr( dt_, 1 ); return *this; } Iterator operator++(int) { // postfix Iterator before = (*this); DateLogic::incr( dt_, 1 ); return before; } Iterator& operator+=( const unsigned long& rhs ) { DateLogic::incr( dt_, rhs ); return *this; } Iterator& operator--() { // prefix DateLogic::decr( dt_, 1 ); return *this; } Iterator operator--(int) { // postfix Iterator before = (*this); DateLogic::decr( dt_, 1 ); return before; } Iterator& operator-=( const unsigned long& rhs ) { DateLogic::decr( dt_, rhs ); return *this; } protected: DateTime dt_; }; #endif //VCF__BCC friend class DateTimeSpan;protected: void setAndAdjustForGregorianDay( const unsigned long& year, const unsigned long& month, const unsigned long& day, const unsigned long& hour, const unsigned long& minutes, const unsigned long& seconds, const unsigned long& milliseconds ); static void setCurrent( DateTime& dt ); /** time is stored as the number of milliseconds since 1 January 4713 BC. This is also known as the Julian Day used by astronomers */ ulong64 time_;};#if defined(VCF_BCC) || defined(__INTEL_COMPILER) || defined(VCF_CW) || defined(VCF_MINGW) || defined(VCF_GCC) template <typename DateLogic> class DateTime::Iterator { public: Iterator() { } Iterator( const DateTime& dt ) : dt_(dt){ } Iterator& operator=( const DateTime& dt ) { dt_ = dt; return *this; } DateTime& operator* () { return dt_; } bool operator==( const Iterator& rhs ) const { return dt_ == rhs.dt_; } bool operator!=( const Iterator& rhs ) const { return dt_ != rhs.dt_; } Iterator& operator++() { // prefix DateLogic::incr( dt_, 1 ); return *this; } Iterator operator++(int) { // postfix Iterator before = (*this); DateLogic::incr( dt_, 1 ); return before; } Iterator& operator+=( const unsigned long& rhs ) { DateLogic::incr( dt_, rhs ); return *this; } Iterator& operator--() { // prefix DateLogic::decr( dt_, 1 ); return *this; } Iterator operator--(int) { // postfix Iterator before = (*this); DateLogic::decr( dt_, 1 ); return before; } Iterator& operator-=( const unsigned long& rhs ) { DateLogic::decr( dt_, rhs ); return *this; } protected: DateTime dt_; };#endif/**\class ByMillisecond DateTime.h "vcf/FoundationKit/DateTime.h"*/class FOUNDATIONKIT_API ByMillisecond {public : static void incr( DateTime& dt, unsigned long offset ); static void decr( DateTime& dt, unsigned long offset );};/**\class ByMillisecond DateTime.h "vcf/FoundationKit/DateTime.h"*/class FOUNDATIONKIT_API BySecond {public : static void incr( DateTime& dt, unsigned long offset ); static void decr( DateTime& dt, unsigned long offset );};/**\class ByMillisecond DateTime.h "vcf/FoundationKit/DateTime.h"*/class FOUNDATIONKIT_API ByMinute {public : static void incr( DateTime& dt, unsigned long offset ); static void decr( DateTime& dt, unsigned long offset );};/**\class ByMillisecond DateTime.h "vcf/FoundationKit/DateTime.h"*/class FOUNDATIONKIT_API ByHour {public : static void incr( DateTime& dt, unsigned long offset ); static void decr( DateTime& dt, unsigned long offset );};/**\class ByMillisecond DateTime.h "vcf/FoundationKit/DateTime.h"*/class FOUNDATIONKIT_API ByDay {public : static void incr( DateTime& dt, unsigned long offset ); static void decr( DateTime& dt, unsigned long offset );};/**\class ByMillisecond DateTime.h "vcf/FoundationKit/DateTime.h"*/class FOUNDATIONKIT_API ByMonth {public : static void incr( DateTime& dt, unsigned long offset ); static void decr( DateTime& dt, unsigned long offset );};/**\class ByMillisecond DateTime.h "vcf/FoundationKit/DateTime.h"*/class FOUNDATIONKIT_API ByYear {public : static void incr( DateTime& dt, unsigned long offset ); static void decr( DateTime& dt, unsigned long offset );};/**\class DateTimeSpan DateTime.h "vcf/FoundationKit/DateTime.h"The DateTimeSpan represents an absolute delta value between two date timevalues. You can get the individual components of the span by calling the variousgetYears(), getMonths(), etc methods, or you can get the total amount of timethis span covers in a praticular format, such the total minutes, or the totalseconds. An example of this might look like so:\codeDateTime dt1(2003,2,10); //2003, Feb 10thDateTime dt2(2003,2,23); //2003, Feb 23rdDateTimeSpan span = dt1 - dt2;int totalHours = span.getTotalHours();//returns 312 (or 24 * 13)int totalMinutes = span.getTotalMinutes(); //returns 18,720 (or 60 * 24 * 13)int days = span.getDays(); //returns 13int months = span.getMonths(); //returns 0int minutes = span.getMinutes(); //returns 0\endcode*/class FOUNDATIONKIT_API DateTimeSpan {public: DateTimeSpan() :years_(0), months_(0), days_(0) { } DateTimeSpan( const DateTimeSpan& rhs ) { *this = rhs; } DateTimeSpan& operator= ( const DateTimeSpan& rhs ) { delta_ = rhs.delta_ ; start_ = rhs.start_ ; end_ = rhs.end_ ; years_ = rhs.years_ ; months_ = rhs.months_; days_ = rhs.days_ ; return *this; } /** allows conversion to a ulong64 ( POD ) data type */ operator ulong64() const { return delta_; } /** returns the number of years in this span of time */ unsigned long getYears() const ; /** returns the number of months in this span of time */ unsigned long getMonths() const ; /** returns the number of days in this span of time */ unsigned long getDays() const ; /** returns the number of hours in this span of time */ unsigned long getHours() const ; /** returns the number of minutes in this span of time */ unsigned long getMinutes() const ; /** returns the number of seconds in this span of time */ unsigned long getSeconds() const ; /** returns the number of milliseconds in this span of time */ unsigned long getMilliseconds() const ; /** returns the total number of whole months if this span of time is evaluated in months as the unit of measurement */ unsigned long getTotalMonths() const ; /** returns the total number of whole days if this span of time is evaluated in days as the unit of measurement */ unsigned long getTotalDays() const ; /** returns the total number of whole hours if this span of time is evaluated in hours as the unit of measurement */ unsigned long getTotalHours() const ; /** returns the total number of whole minutes if this span of time is evaluated in minutes as the unit of measurement */ unsigned long getTotalMinutes() const ; /** returns the total number of whole seconds if this span of time is evaluated in seconds as the unit of measurement */ unsigned long getTotalSeconds() const ; /** returns the total number of whole milliseconds if this span of time is evaluated in milliseconds as the unit of measurement */ ulong64 getTotalMilliseconds() const ; friend class DateTime;protected: void subtract( const DateTime& lhs, const DateTime& rhs ); DateTimeSpan& operator=( const ulong64& rhs ) { delta_ = rhs; return *this; } ulong64 delta_; ulong64 start_; ulong64 end_; unsigned long years_; unsigned long months_; unsigned long days_;};///////////////////////////////////////////////////////////////////////////////// DateTime inlinesinline void DateTime::getDate( unsigned long* year, unsigned long* month, unsigned long* day ) const { getYearMonthDay( *this, year, month, day );}inline void DateTime::getTime( unsigned long* hour, unsigned long* minute, unsigned long* second, unsigned long* millsecond/*=NULL*/ ) const { getHourMinuteSecond( *this, hour, minute, second, millsecond );}inline void DateTime::get( unsigned long* year, unsigned long* month, unsigned long* day, unsigned long* hour, unsigned long* minute, unsigned long* second, unsigned long* millsecond/*=NULL*/ ) const { getYearMonthDay( *this, year, month, day ); getHourMinuteSecond( *this, hour, minute, second, millsecond );}};/***CVS Log info*$Log$*Revision 1.7 2006/04/07 02:35:34 ddiego*initial checkin of merge from 0.6.9 dev branch.**Revision 1.6.2.5 2006/03/26 22:37:34 ddiego*minor update to source docs.**Revision 1.6.2.4 2006/03/19 00:04:16 obirsoy*Linux FoundationKit improvements.**Revision 1.6.2.3 2006/03/12 22:01:40 ddiego*doc updates.**Revision 1.6.2.2 2005/11/10 00:03:48 obirsoy*changes required for gcc under Linux.**Revision 1.6.2.1 2005/10/07 19:31:53 ddiego*merged patch 1315995 and 1315991 into dev repos.**Revision 1.6 2005/07/18 03:54:19 ddiego*documentation updates.**Revision 1.5 2005/07/09 23:15:02 ddiego*merging in changes from devmain-0-6-7 branch.**Revision 1.4 2004/12/10 16:39:56 marcelloptr*added postfix iterator for the DateTime::Iterator**Revision 1.3.2.3 2005/04/11 17:07:09 iamfraggle*Changes allowing compilation of Win32 port under CodeWarrior**Revision 1.3.2.2 2004/12/07 23:15:31 marcelloptr*added postfix iterator for the DateTime::Iterator**Revision 1.3 2004/12/01 04:31:40 ddiego*merged over devmain-0-6-6 code. Marcello did a kick ass job*of fixing a nasty bug (1074768VCF application slows down modal dialogs.)*that he found. Many, many thanks for this Marcello.**Revision 1.2.2.5 2004/10/18 23:18:19 augusto_roman*Fixed DateTime iterator declaration to work with the intel compiler - aroman**Revision 1.2.2.4 2004/08/26 04:05:47 marcelloptr*minor change on name of getMillisecond**Revision 1.2.2.3 2004/08/23 21:24:04 marcelloptr*just moved some member declarations around**Revision 1.2.2.1 2004/08/11 04:49:36 marcelloptr*added conversion operator to ulong64**Revision 1.2 2004/08/07 02:49:13 ddiego*merged in the devmain-0-6-5 branch to stable**Revision 1.1.2.9 2004/08/06 01:45:04 ddiego*updated and added Marcellos DateTime changes.**Revision 1.1.2.8 2004/08/03 20:57:22 marcelloptr*minor change on name DateTime:getSecond DateTime:getMillisecond**Revision 1.1.2.7 2004/07/30 17:28:40 kiklop74*Added first release of Borland midifications for VCF**Revision 1.1.2.6 2004/07/24 01:40:42 ddiego*committed changes requested by Marcello. Got rid of the remaining*date time members on the File class - now the dat time function call the*FilePeer directly each time. Also added 2 functions to DateTime to convert*directly to UTC or Local time.**Revision 1.1.2.5 2004/07/13 16:16:23 marcelloptr*added a comment**Revision 1.1.2.4 2004/06/25 20:02:14 marcelloptr*minor fix**Revision 1.1.2.3 2004/06/06 07:05:32 marcelloptr*changed macros, text reformatting, copyright sections**Revision 1.1.2.2 2004/04/29 04:07:07 marcelloptr*reformatting of source files: macros and csvlog and copyright sections**Revision 1.1.2.1 2004/04/28 03:29:39 ddiego*migration towards new directory structure**Revision 1.2.2.3 2004/04/26 21:58:48 marcelloptr*changes for dir reorganization: _VCF_MACRO_H__**Revision 1.2.2.2 2004/04/21 02:17:23 ddiego*checking in change to FoundationKit, GraphicsKit and Application*Kit to support unicode in Win32**Revision 1.2.2.1 2004/04/06 17:19:15 ddiego*minor header changes to better facilitate compiling with*mingw. Also some minor changes to the devcpp FoundationKit project.**Revision 1.2 2004/01/20 01:54:55 ddiego*merged some more changes from dev branch, primarily changes to*teh RTTI API so that we now process enum sets correctly (i.e. a long*that is a mask made of enum values).**Revision 1.1.2.3 2004/01/17 18:47:30 ddiego*added a new example for DateTime calss and some other minor fixes to it**Revision 1.1.2.2 2004/01/17 06:09:50 ddiego*integrated the DateTime class into the VCF FoundationKit.**/#endif // _VCF_DATETIME_H__
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?