X-Git-Url: http://www.andromeda.nl/gitweb/?a=blobdiff_plain;f=src%2Fdate.h;fp=src%2Fdate.h;h=0000000000000000000000000000000000000000;hb=446d39140f5a32d04d9a5a05620a9bb2eb816de1;hp=2a500d41af11888371ff5e3b44dcf4719cddc298;hpb=35089ead71590d9055a7d83f1b63772f5d4fbbf0;p=AXE.git diff --git a/src/date.h b/src/date.h deleted file mode 100644 index 2a500d4..0000000 --- a/src/date.h +++ /dev/null @@ -1,293 +0,0 @@ -/************************************************************************** -** (c) Copyright 1999, Andromeda Technology & Automation -*************************************************************************** -** MODULE INFORMATION * -*********************** -** FILE NAME : date.h -** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation -** VERSION NUMBER : $Revision: 1.3 $ -** -** DESCRIPTION : -** -** EXPORTED OBJECTS : -** LOCAL OBJECTS : -** MODULES USED : -*************************************************************************** -** ADMINISTRATIVE INFORMATION * -******************************** -** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl -** CREATION DATE : Feb 06, 1998 -** LAST UPDATE : Oct 16, 1999 -** MODIFICATIONS : -**************************************************************************/ - -/***************************** - $Log: date.h,v $ - Revision 1.3 2002-09-28 06:58:45 arjen - Bugfix: conversion of an empty string to a date or hour object - now makes the values of such an object 0 (null) instead of giving - a segmentation fault. - The class UTC combines the date and hour classes. The most basic - functions of the UTC class are now implemented. - These include constructors and conversion to and from String objects. - New functions: date::proper(), hour::proper() and UTC::proper(). - Return true if the object holds a proper clock time and/or calendar - date; false if at least one value is out of range. - - Revision 1.2 2002/09/02 06:18:20 arjen - Fixed some date and time conversion functions - - Revision 1.1 2002/07/25 08:01:26 arjen - First checkin, AXE release 0.2 - -*****************************/ - -/* static const char *RCSID = "$Id: date.h,v 1.3 2002-09-28 06:58:45 arjen Exp $"; */ - -#ifndef AXE_DATE_H -#define AXE_DATE_H - -#include "String.h" - -class date -{ - unsigned char month, day; - short year; - - long julian(); - date add(date D); - date add(unsigned long days); - - date subtract(unsigned long days); - - friend class UTC; - -public: - - date() - { - month = 0; - day = 0; - year = 0; - } - - date(unsigned d, unsigned m=0, short y=0) - { - day = d; - month = m; - year = y; - } - - date(String s); - - bool proper(); // Check wether this is a proper calendar date - - friend date operator+(date, date); - friend date operator+(unsigned long, date); - friend date operator+(date, unsigned long); - - date operator += (date D) - { - return add(D); - } - - date operator += (unsigned long l) - { - return add(l); - } - - friend date operator-(unsigned long, date); - friend date operator-(date, unsigned long); - friend long operator-(date&, date&); - - date operator -= (unsigned long l) - { - return subtract(l); - } - -// long(date); // Calculate nr. of days since... - - int operator==(date d) - { - register int cm; - - cm = this->year - d.year; - cm = (cm != 0) ? cm : this->month - d.month; - cm = (cm != 0) ? cm : this->day - d.day; - - return cm == 0; - } - - int operator!=(date d) - { - register int cm; - - cm = this->year - d.year; - cm = (cm != 0) ? cm : this->month - d.month; - cm = (cm != 0) ? cm : this->day - d.day; - - return cm != 0; - } - - int operator<=(date d) - { - register int cm; - - cm = this->year - d.year; - cm = (cm != 0) ? cm : this->month - d.month; - cm = (cm != 0) ? cm : this->day - d.day; - - return cm <= 0; - } - - int operator>=(date d) - { - register int cm; - - cm = this->year - d.year; - cm = (cm != 0) ? cm : this->month - d.month; - cm = (cm != 0) ? cm : this->day - d.day; - - return cm >= 0; - } - - int operator>(date d) - { - register int cm; - - cm = this->year - d.year; - cm = (cm != 0) ? cm : this->month - d.month; - cm = (cm != 0) ? cm : this->day - d.day; - - return cm > 0; - } - - int operator<(date d) - { - register int cm; - - cm = this->year - d.year; - cm = (cm != 0) ? cm : this->month - d.month; - cm = (cm != 0) ? cm : this->day - d.day; - - return cm < 0; - } - - // Attributes. - - unsigned Day() - { - return day; - } - - unsigned Month() - { - return month; - } - - String MonthName(void); - - int Year() - { - return year; - } - // Operations. - - int Leap(void); - unsigned DaysInMonth(); - -// date operator*(double) -// date& operator*=(double) -// date operator/(double) -// date& operator/=(double) - - friend std::ostream& operator<<(std::ostream&, const date&); - friend std::istream& operator>>(std::istream&, date&); - - String format(const char *fmt = "%F"); -}; - -date today(); - -class hour -{ - int hours; - short minutes, seconds; - - friend class UTC; - -public: - - hour() - { - hours = 0; - minutes = 0; - seconds = 0; - } - - hour(int hr, short minute, short sec) - { - hours = hr; - minutes = minute; - seconds = sec; - } - - hour(String s); - - bool proper(); // Check wether this is a proper clock time - - friend hour operator+(hour &, hour &); - hour operator += (hour h); - friend hour operator-(hour &, hour &); - - friend std::ostream& operator<<(std::ostream &, const hour &); - friend std::istream& operator>>(std::istream &, hour &); - - String format(const char *fmt = "%T"); -}; - -hour now(); - -class UTC -{ - hour t; - date d; - -public: - - UTC() - { - /* Leave everything to the default hour and date constructors */ - } - - UTC(const String s); - UTC(date dt, hour tm) - { - d = dt; - t = tm; - } - - operator date() - { - return d; - } - - operator hour() - { - return t; - } - - bool proper() - { - return d.proper() && t.proper(); - } - - friend std::ostream& operator<<(std::ostream &, const UTC &); - friend std::istream& operator>>(std::istream &, UTC &); - - String format(const char *fmt = "%F %T"); -}; - -UTC Now(); - -#endif /* AXE_DATE_H */