Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Fl_Date_Time.h

00001 /*
00002  * $Id: Fl_Date_Time.h,v 1.11 2003/03/15 16:09:55 laza2000 Exp $
00003  *
00004  * Extended Fast Light Toolkit (EFLTK)
00005  * Copyright (C) 2002-2003 by EDE-Team
00006  * WWW: http://www.sourceforge.net/projects/ede
00007  *
00008  * Fast Light Toolkit (FLTK)
00009  * Copyright (C) 1998-2003 by Bill Spitzak and others.
00010  * WWW: http://www.fltk.org
00011  *
00012  * This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00013  * version 2. See COPYING for details.
00014  *
00015  * Author : Alexey Parshin
00016  * Email  : alexey@fltk.net
00017  *
00018  * Please report all bugs and problems to "efltk-bugs@fltk.net"
00019  *
00020  */
00021 
00022 #ifndef _FL_DATE_TIME_H_
00023 #define _FL_DATE_TIME_H_
00024 
00025 #include "Fl_Export.h"
00026 #include "Fl_String.h"
00027 
00029 class FL_API Fl_Date_Time {
00030 public:
00031     static char   dateInputFormat[32];
00032     static char   timeInputFormat[32];
00033     static char   dateFormat[32];
00034     static char   timeFormat[32];
00035     static char   datePartsOrder[4];
00036     static char   dateSeparator;
00037     static char   timeSeparator;
00038     static bool   time24Mode;
00039 
00040     Fl_Date_Time (short y,short m,short d,short hour=0,short minute=0,short second=0);
00041     Fl_Date_Time (const char * dat);
00042     Fl_Date_Time (const Fl_Date_Time &dt);
00043     Fl_Date_Time (const double dt=0);
00044 
00045     static Fl_Date_Time convert (const long);
00046 
00047     void format_date(char *str) const;
00048     void format_time(char *str, bool ampm=true) const;
00049 
00050     // These functions don't affect the actual system time.
00051     // You can only alter the time for the current program.
00052     static void Now(Fl_Date_Time dt);      // Sets to current date and time
00053     static Fl_Date_Time System();          // Gets to current system date and time
00054     static Fl_Date_Time Now();             // Gets to current date and time
00055     static Fl_Date_Time Date();            // Gets to current date
00056     static Fl_Date_Time Time();            // Gets to current time
00057 
00058     short days_in_month() const;           // Number of days in month (1..31)
00059     short day_of_week() const;             // (1..7)
00060     short day_of_year() const;             // returns relative date since Jan. 1
00061 
00062     Fl_String day_name() const;            // Character Day Of Week ('Sunday'..'Saturday')
00063     Fl_String month_name() const;          // Character Month name
00064 
00065     unsigned date() const;                 // Numeric date of date object
00066     short day() const;                     // Numeric day of date object
00067     short month() const;                   // Month number (1..12)
00068     short year() const;
00069 
00070     Fl_String date_string() const;
00071     Fl_String time_string() const;
00072 
00073     void decode_date(short *y,short *m,short *d) const;
00074     void decode_time(short *h,short *m,short *s,short *ms) const;
00075 
00076     operator double (void) const;
00077 
00078     void operator = (const Fl_Date_Time& date);
00079     void operator = (const char * dat);
00080 
00081     Fl_Date_Time  operator + (int i);
00082     Fl_Date_Time  operator - (int i);
00083     Fl_Date_Time  operator + (Fl_Date_Time& dt);
00084     Fl_Date_Time  operator - (Fl_Date_Time& dt);
00085 
00086     Fl_Date_Time& operator += (int i);
00087     Fl_Date_Time& operator -= (int i);
00088     Fl_Date_Time& operator += (Fl_Date_Time& dt);
00089     Fl_Date_Time& operator -= (Fl_Date_Time& dt);
00090 
00091     Fl_Date_Time& operator ++ ();     // Prefix increment
00092     Fl_Date_Time& operator ++ (int);  // Postfix increment
00093     Fl_Date_Time& operator -- ();     // Prefix decrement
00094     Fl_Date_Time& operator -- (int);  // Postfix decrement
00095 
00096     static void   decode_date(const double dt,short& y,short& m,short& d);
00097     static void   decode_time(const double dt,short& h,short& m,short& s,short& ms);
00098     static void   encode_date(double &dt,short y=0,short m=0,short d=0);
00099     static void   encode_date(double &dt,const char *dat);
00100     static void   encode_time(double &dt,short h=0,short m=0,short s=0,short ms=0);
00101     static void   encode_time(double &dt,const char *tim);
00102     static bool   is_leap_year(const short year);
00103 
00104 protected:
00105     double        m_dateTime;
00106     static double dateTimeOffset;    // The offset from current' system time for synchronization
00107     // with outside system
00108 };
00109 
00110 // Date comparison
00111 static inline bool operator <  (const Fl_Date_Time &dt1, const Fl_Date_Time &dt2) { return ( (double)dt1 <  (double)dt2 ); }
00112 static inline bool operator <= (const Fl_Date_Time &dt1, const Fl_Date_Time &dt2) { return ( (double)dt1 <= (double)dt2 ); }
00113 static inline bool operator >  (const Fl_Date_Time &dt1, const Fl_Date_Time &dt2) { return ( (double)dt1 >  (double)dt2 ); }
00114 static inline bool operator >= (const Fl_Date_Time &dt1, const Fl_Date_Time &dt2) { return ( (double)dt1 >= (double)dt2 ); }
00115 static inline bool operator == (const Fl_Date_Time &dt1, const Fl_Date_Time &dt2) { return ( (double)dt1 == (double)dt2 ); }
00116 static inline bool operator != (const Fl_Date_Time &dt1, const Fl_Date_Time &dt2) { return ( (double)dt1 != (double)dt2 ); }
00117 
00118 #endif

Generated on Thu Jul 31 15:33:43 2003 for eFLTK by doxygen1.2.15