⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 time.ho

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 HO
字号:
#ifndef TIME_H
#define TIME_H

/*$Header: D:\plustest\regress\nih\x:\groupdir\cproj\plustest\regress\nih\rcs\time.ho 1.1 90/05/20 02:21:48 Anthony_Scian Exp $*/

/* Time.h -- declarations for class Time

        THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
        "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
        AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
        CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
        PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
        RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.

Author:
        K. E. Gorlen
        Computer Systems Laboratory, DCRT
        National Institutes of Health
        Bethesda, MD 20892

$Log:   time.ho $
Revision 1.1  90/05/20  02:21:48  Anthony_Scian
.

 * Revision 3.0  90/05/20  00:21:46  kgorlen
 * Release for 1st edition.
 * 
*/

#include "Object.h"

class Date;

#ifndef NESTED_TYPES
typedef unsigned short hourTy;
typedef unsigned short minuteTy;
typedef unsigned short secondTy;
typedef unsigned long clockTy;
#endif

class Time: public VIRTUAL Object {
        DECLARE_MEMBERS(Time);
public:                 // type definitions
#ifdef NESTED_TYPES
        typedef unsigned short hourTy;
        typedef unsigned short minuteTy;
        typedef unsigned short secondTy;
        typedef unsigned long clockTy;
#endif
private:
        clockTy sec;                    /* seconds since 1/1/1901 */
        bool isDST() const;
        Time localTime() const;
private:                // static member functions
        static Time localTime(const Date& date, hourTy h=0, minuteTy m=0, secondTy s=0);
        static Time beginDST(unsigned year);
        static Time endDST(unsigned year);
protected:              // storer() functions for object I/O
        virtual void storer(OIOofd&) const;
        virtual void storer(OIOout&) const;
public:
        Time();                         // current time 
        Time(clockTy s)                 { sec = s; }
        Time(hourTy h, minuteTy m, secondTy s =0, bool dst =NO);
        Time(const Date&, hourTy h =0, minuteTy m =0, secondTy s=0, bool dst =NO);
        operator Date() const;
        bool operator<(const Time& t) const     { return sec < t.sec; }
        bool operator<=(const Time& t) const    { return sec <= t.sec; }
        bool operator>(const Time& t) const     { return sec > t.sec; }
        bool operator>=(const Time& t) const    { return sec >= t.sec; }
        bool operator==(const Time& t) const    { return sec == t.sec; }
        bool operator!=(const Time& t) const    { return sec != t.sec; }
        friend Time operator+(const Time& t, long s)    { return Time(t.sec+s); }
        friend Time operator+(long s, const Time& t)    { return Time(t.sec+s); }
        long operator-(const Time& t) const     { return sec - t.sec; }
        Time operator-(long s) const    { return Time(sec-s); }
        void operator+=(long s)         { sec += s; }
        void operator-=(long s)         { sec -= s; }
        bool between(const Time& a, const Time& b) const;
        hourTy hour() const;            // hour in local time 
        hourTy hourGMT() const;         // hour in GMT 
        minuteTy minute() const;        // minute in local time 
        minuteTy minuteGMT() const;     // minute in GMT 
        secondTy second() const;        // second in local time or GMT 
        clockTy seconds() const         { return sec; }
        Time max(const Time&) const;
        Time min(const Time&) const;
        virtual int compare(const Object&) const;
        virtual void deepenShallowCopy();       // {}
        virtual unsigned hash() const;
        virtual bool isEqual(const Object&) const;
        virtual void printOn(ostream& strm =cout) const;
        virtual const Class* species() const;
};

#endif /* TIMEH */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -