00001
00002 #ifndef TimeFuncsH
00003 #define TimeFuncsH
00004
00005
00006 #include <time.h>
00007 #include <worm_statuscode.h>
00008
00009
00010
00011 enum WORM_TIME_LOCALE
00012 {
00013 WORM_GMT_TIME
00014 , WORM_LOCAL_TIME
00015 };
00016
00017 enum WORM_TIME_FORMAT
00018 {
00019 WORM_TIMEFMT_8 = 0
00020 , WORM_TIMEFMT_14 = 1
00021 , WORM_TIMEFMT_18 = 2
00022 , WORM_TIMEFMT_UTC21 = 3
00023 , WORM_TIMEFMT_16 = 4
00024 , WORM_TIMEFMT_19 = 5
00025 , WORM_TIMEFMT_23 = 6
00026 , WORM_TIMEFMT_26 = 7
00027 };
00028
00029 #define WORM_TIMESTR_LENGTH 26 // max length (with terminator) of above formats
00030
00031 typedef char WORM_DATETIMESTR[WORM_TIMESTR_LENGTH];
00032
00033 typedef unsigned long ULONG_TIME;
00034
00035
00036
00037
00038 typedef double HIGHRES_TIME;
00039
00040
00041
00042
00043 class TTimeFuncs
00044 {
00045 protected:
00046
00047 static const short MONTH_STARTS[2][12];
00048
00049 public:
00050
00051 static const char DOW[7][4];
00052
00053 static const char MOY[12][4];
00054
00055
00056 static HIGHRES_TIME GetHighResTime();
00057
00058
00059
00060
00061
00062
00063
00064 static char * DateString( char * r_buffer
00065 , WORM_TIME_FORMAT p_format
00066 , WORM_TIME_LOCALE p_locale = WORM_GMT_TIME
00067 , double p_time = -1.0
00068 );
00069
00070
00071
00072
00073
00074 static double TimeToDouble( const char * p_buffer );
00075
00076 static void MSecSleep( unsigned int p_msec );
00077
00078 static bool IsLeapyear( unsigned int p_year );
00079
00080 static bool YearJulianToMonDay( short p_year
00081 , short p_julday
00082 , short * r_monthnum
00083 , short * r_monthday
00084 );
00085
00086 static bool CrackDate( const char * p_buffer
00087 , short * r_year
00088 , short * r_monthnum
00089 , short * r_monthday
00090 , short * r_year2
00091 , short * r_julday = NULL
00092 , bool * r_isleap = NULL
00093 );
00094
00095
00096
00097 static bool CrackTime( const char * p_buffer
00098 , short * p_hour
00099 , short * p_min
00100 , short * p_sec = NULL
00101 , short * p_msec = NULL
00102 , double * p_fpsec = NULL
00103 );
00104 };
00105
00106 #endif