mux/src/timeutil.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  FIELDEDTIME
class  CLinearTimeAbsolute
class  CLinearTimeDelta
class  CMuxAlarm

Defines

#define FACTOR_NANOSECONDS_PER_100NS   100
#define FACTOR_100NS_PER_MICROSECOND   10
#define FACTOR_100NS_PER_MILLISECOND   10000
#define EPOCH_OFFSET   116444736000000000ll
#define EARLIEST_VALID_DATE   (-9106391088000000000ll)
#define LATEST_VALID_DATE   ( 9222834959999999999ll)
#define TIMEUTIL_TIME_T_MIN_VALUE   (-922283539200ll)
#define TIMEUTIL_TIME_T_MAX_VALUE   ( 910638979199ll)

Functions

bool FieldedTimeToLinearTime (FIELDEDTIME *ft, INT64 *plt)
bool LinearTimeToFieldedTime (INT64 lt, FIELDEDTIME *ft)
void TIME_Initialize (void)
DCL_INLINE INT64 i64Mod (INT64 x, INT64 y)
DCL_INLINE INT64 i64FloorDivision (INT64 x, INT64 y)
INT64 i64Division (INT64 x, INT64 y)
INT64 i64Remainder (INT64 x, INT64 y)
int DCL_INLINE iFloorDivisionMod (int x, int y, int *piMod)
bool ParseDate (CLinearTimeAbsolute &lta, char *pDateString, bool *pbZoneSpecified)
bool isLeapYear (long iYear)
int iMod (int x, int y)

Variables

CMuxAlarm MuxAlarm
const INT64 FACTOR_100NS_PER_SECOND
const INT64 FACTOR_100NS_PER_MINUTE
const INT64 FACTOR_100NS_PER_HOUR
const INT64 FACTOR_100NS_PER_DAY
const INT64 FACTOR_100NS_PER_WEEK
const CLinearTimeDelta time_200us = 200*FACTOR_100NS_PER_MICROSECOND
const CLinearTimeDelta time_5ms = 5*FACTOR_100NS_PER_MILLISECOND
const CLinearTimeDelta time_250ms = 250*FACTOR_100NS_PER_MILLISECOND
const CLinearTimeDelta time_1s = FACTOR_100NS_PER_SECOND
const CLinearTimeDelta time_15s = 15*FACTOR_100NS_PER_SECOND
const CLinearTimeDelta time_30s = 30*FACTOR_100NS_PER_SECOND
const CLinearTimeDelta time_45s = 45*FACTOR_100NS_PER_SECOND
const CLinearTimeDelta time_15m = 15*FACTOR_100NS_PER_MINUTE
const CLinearTimeDelta time_30m = 30*FACTOR_100NS_PER_MINUTE
const CLinearTimeDelta time_1w = FACTOR_100NS_PER_WEEK
const char * monthtab []
char * DayOfWeekString []


Define Documentation

#define EARLIEST_VALID_DATE   (-9106391088000000000ll)

Definition at line 166 of file timeutil.h.

Referenced by CLinearTimeAbsolute::SetSecondsString().

#define EPOCH_OFFSET   116444736000000000ll

Definition at line 165 of file timeutil.h.

Referenced by GetUTCLinearTime(), CLinearTimeAbsolute::ReturnSeconds(), CLinearTimeAbsolute::ReturnSecondsString(), CLinearTimeAbsolute::SetSeconds(), and CLinearTimeAbsolute::SetSecondsString().

#define FACTOR_100NS_PER_MICROSECOND   10

Definition at line 156 of file timeutil.h.

Referenced by FieldedTimeToLinearTime(), GetUTCLinearTime(), LinearTimeToFieldedTime(), CLinearTimeDelta::ReturnMicroseconds(), CLinearTimeDelta::ReturnTimeValueStruct(), and CLinearTimeDelta::SetTimeValueStruct().

#define FACTOR_100NS_PER_MILLISECOND   10000

Definition at line 157 of file timeutil.h.

Referenced by FieldedTimeToLinearTime(), LinearTimeToFieldedTime(), CLinearTimeDelta::ReturnMilliseconds(), and CLinearTimeDelta::SetMilliseconds().

#define FACTOR_NANOSECONDS_PER_100NS   100

Definition at line 155 of file timeutil.h.

Referenced by FieldedTimeToLinearTime(), and LinearTimeToFieldedTime().

#define LATEST_VALID_DATE   ( 9222834959999999999ll)

Definition at line 167 of file timeutil.h.

Referenced by CLinearTimeAbsolute::SetSecondsString().

#define TIMEUTIL_TIME_T_MAX_VALUE   ( 910638979199ll)

Definition at line 169 of file timeutil.h.

Referenced by time_t_largest().

#define TIMEUTIL_TIME_T_MIN_VALUE   (-922283539200ll)

Definition at line 168 of file timeutil.h.

Referenced by time_t_smallest().


Function Documentation

bool FieldedTimeToLinearTime ( FIELDEDTIME ft,
INT64 plt 
)

Definition at line 1333 of file timeutil.cpp.

References FACTOR_100NS_PER_MICROSECOND, FACTOR_100NS_PER_MILLISECOND, FACTOR_NANOSECONDS_PER_100NS, FixedFromGregorian_Adjusted(), FIELDEDTIME::iDayOfMonth, FIELDEDTIME::iDayOfWeek, FIELDEDTIME::iHour, FIELDEDTIME::iMicrosecond, FIELDEDTIME::iMillisecond, FIELDEDTIME::iMinute, iMod(), FIELDEDTIME::iMonth, FIELDEDTIME::iNanosecond, FIELDEDTIME::iSecond, isValidDate(), and FIELDEDTIME::iYear.

Referenced by CLinearTimeAbsolute::SetFields(), and CLinearTimeAbsolute::SetString().

01334 {
01335     if (!isValidDate(ft->iYear, ft->iMonth, ft->iDayOfMonth))
01336     {
01337         *plt = 0;
01338         return false;
01339     }
01340 
01341     int iFixedDay = FixedFromGregorian_Adjusted(ft->iYear, ft->iMonth, ft->iDayOfMonth);
01342     ft->iDayOfWeek = iMod(iFixedDay+1, 7);
01343 
01344     INT64 lt;
01345     lt  = iFixedDay * FACTOR_100NS_PER_DAY;
01346     lt += ft->iHour * FACTOR_100NS_PER_HOUR;
01347     lt += ft->iMinute * FACTOR_100NS_PER_MINUTE;
01348     lt += ft->iSecond * FACTOR_100NS_PER_SECOND;
01349     lt += ft->iMicrosecond * FACTOR_100NS_PER_MICROSECOND;
01350     lt += ft->iMillisecond * FACTOR_100NS_PER_MILLISECOND;
01351     lt += ft->iNanosecond / FACTOR_NANOSECONDS_PER_100NS;
01352 
01353     *plt = lt;
01354     return true;
01355 }

INT64 i64Division ( INT64  x,
INT64  y 
)

Referenced by FUNCTION().

DCL_INLINE INT64 i64FloorDivision ( INT64  x,
INT64  y 
)

Definition at line 201 of file timeutil.h.

00201 { return x / y; }

DCL_INLINE INT64 i64Mod ( INT64  x,
INT64  y 
)

Definition at line 200 of file timeutil.h.

00200 { return x % y; }

INT64 i64Remainder ( INT64  x,
INT64  y 
)

Referenced by FUNCTION().

int DCL_INLINE iFloorDivisionMod ( int  x,
int  y,
int *  piMod 
)

Definition at line 204 of file timeutil.h.

00205 {                   \
00206     *piMod = x % y; \
00207     return x / y;   \
00208 }

int iMod ( int  x,
int  y 
)

Definition at line 54 of file timeutil.cpp.

Referenced by crypt_code(), do_comlast(), FieldedTimeToLinearTime(), GregorianFromFixed(), isLeapYear(), and SendChannelMessage().

00055 {
00056     if (y < 0)
00057     {
00058         if (x <= 0)
00059         {
00060             return x % y;
00061         }
00062         else
00063         {
00064             return ((x-1) % y) + y + 1;
00065         }
00066     }
00067     else
00068     {
00069         if (x < 0)
00070         {
00071             return ((x+1) % y) + y - 1;
00072         }
00073         else
00074         {
00075             return x % y;
00076         }
00077     }
00078 }

bool isLeapYear ( long  iYear  ) 

Definition at line 796 of file timeutil.cpp.

References iMod().

Referenced by FixedFromGregorian(), FUNCTION(), GregorianFromFixed(), isValidDate(), and YearType().

00797 {
00798     if (iMod(iYear, 4) != 0)
00799     {
00800         // Not a leap year.
00801         //
00802         return false;
00803     }
00804     unsigned long wMod = iMod(iYear, 400);
00805     if ((wMod == 100) || (wMod == 200) || (wMod == 300))
00806     {
00807         // Not a leap year.
00808         //
00809         return false;
00810     }
00811     return true;
00812 }

bool LinearTimeToFieldedTime ( INT64  lt,
FIELDEDTIME ft 
)

Definition at line 1357 of file timeutil.cpp.

References d0, FACTOR_100NS_PER_MICROSECOND, FACTOR_100NS_PER_MILLISECOND, FACTOR_NANOSECONDS_PER_100NS, GregorianFromFixed_Adjusted(), i64FloorDivisionMod(), FIELDEDTIME::iDayOfMonth, FIELDEDTIME::iDayOfWeek, FIELDEDTIME::iDayOfYear, FIELDEDTIME::iHour, FIELDEDTIME::iMicrosecond, FIELDEDTIME::iMillisecond, FIELDEDTIME::iMinute, FIELDEDTIME::iMonth, FIELDEDTIME::iNanosecond, FIELDEDTIME::iSecond, isValidDate(), and FIELDEDTIME::iYear.

Referenced by CLinearTimeAbsolute::ReturnDateString(), CLinearTimeAbsolute::ReturnFields(), and CLinearTimeAbsolute::ReturnUniqueString().

01358 {
01359     INT64 ns100;
01360     int iYear, iMonth, iDayOfYear, iDayOfMonth, iDayOfWeek;
01361 
01362     memset(ft, 0, sizeof(FIELDEDTIME));
01363     int d0 = (int)i64FloorDivisionMod(lt, FACTOR_100NS_PER_DAY, &ns100);
01364     GregorianFromFixed_Adjusted(d0, iYear, iMonth, iDayOfYear, iDayOfMonth, iDayOfWeek);
01365     if (!isValidDate(iYear, iMonth, iDayOfMonth))
01366     {
01367         return false;
01368     }
01369 
01370     ft->iYear = iYear;
01371     ft->iMonth = iMonth;
01372     ft->iDayOfYear = iDayOfYear;
01373     ft->iDayOfMonth = iDayOfMonth;
01374     ft->iDayOfWeek = iDayOfWeek;
01375 
01376     ft->iHour = (int)(ns100 / FACTOR_100NS_PER_HOUR);
01377     ns100 = ns100 % FACTOR_100NS_PER_HOUR;
01378     ft->iMinute = (int)(ns100 / FACTOR_100NS_PER_MINUTE);
01379     ns100 = ns100 % FACTOR_100NS_PER_MINUTE;
01380     ft->iSecond = (int)(ns100 / FACTOR_100NS_PER_SECOND);
01381     ns100 = ns100 % FACTOR_100NS_PER_SECOND;
01382 
01383     ft->iMillisecond = (int)(ns100 / FACTOR_100NS_PER_MILLISECOND);
01384     ns100 = ns100 % FACTOR_100NS_PER_MILLISECOND;
01385     ft->iMicrosecond = (int)(ns100 / FACTOR_100NS_PER_MICROSECOND);
01386     ns100 = ns100 % FACTOR_100NS_PER_MICROSECOND;
01387     ft->iNanosecond = (int)(ns100 * FACTOR_NANOSECONDS_PER_100NS);
01388 
01389     return true;
01390 }

bool ParseDate ( CLinearTimeAbsolute lta,
char *  pDateString,
bool *  pbZoneSpecified 
)

Definition at line 4045 of file timeutil.cpp.

References ConvertAllFieldsToLinearTime(), tag_AllFields::iMinuteTimeZone, NOT_PRESENT, PD_AppendNode(), PD_BreakItDown(), PD_Deduction(), PD_GetFields(), PD_Pass2(), PD_Pass5(), PD_Pass6(), PD_Reset(), and PD_ScanNextToken().

Referenced by FUNCTION().

04050 {
04051     PD_Reset();
04052 
04053     char *p = pDateString;
04054     PD_Node *pNode;
04055     while ((pNode = PD_ScanNextToken(&p)))
04056     {
04057         PD_AppendNode(pNode);
04058     }
04059 
04060     PD_Pass2();
04061 
04062     PD_Deduction();
04063     PD_BreakItDown();
04064     PD_Pass5();
04065     PD_Pass6();
04066 
04067     PD_Deduction();
04068     PD_BreakItDown();
04069     PD_Pass5();
04070     PD_Pass6();
04071 
04072     ALLFIELDS af;
04073     if (  PD_GetFields(&af)
04074        && ConvertAllFieldsToLinearTime(lt, &af))
04075     {
04076         *pbZoneSpecified = (af.iMinuteTimeZone != NOT_PRESENT);
04077         return true;
04078     }
04079     return false;
04080 }

void TIME_Initialize ( void   ) 

Definition at line 2001 of file timeutil.cpp.

References cnt, FIELDEDTIME::iYear, ltaUpperBound, ltdIntervalMinimum, CLinearTimeAbsolute::ReturnFields(), test_time_t(), time_1w, and YearType().

Referenced by main(), and QueryLocalOffsetAt_Internal().

02002 {
02003     if (bTimeInitialized)
02004     {
02005         return;
02006     }
02007     bTimeInitialized = true;
02008 
02009     tzset();
02010 
02011     test_time_t();
02012     ltdIntervalMinimum = time_1w;
02013     int i;
02014     for (i = 0; i < 15; i++)
02015     {
02016         NearestYearOfType[i] = -1;
02017     }
02018     int cnt = 14;
02019     FIELDEDTIME ft;
02020     ltaUpperBound.ReturnFields(&ft);
02021     for (i = ft.iYear-1; cnt; i--)
02022     {
02023         int iYearType = YearType(i);
02024         if (NearestYearOfType[iYearType] < 0)
02025         {
02026             NearestYearOfType[iYearType] = i;
02027             cnt--;
02028         }
02029     }
02030 #ifdef WIN32
02031     InitializeQueryPerformance();
02032 #endif
02033 }


Variable Documentation

char* DayOfWeekString[]

Definition at line 725 of file timeutil.cpp.

Referenced by FUNCTION().

const INT64 FACTOR_100NS_PER_DAY

Definition at line 410 of file timeutil.cpp.

const INT64 FACTOR_100NS_PER_HOUR

Definition at line 409 of file timeutil.cpp.

const INT64 FACTOR_100NS_PER_MINUTE

Definition at line 408 of file timeutil.cpp.

const INT64 FACTOR_100NS_PER_SECOND

Definition at line 406 of file timeutil.cpp.

const INT64 FACTOR_100NS_PER_WEEK

Definition at line 411 of file timeutil.cpp.

const char* monthtab[]

Definition at line 727 of file timeutil.cpp.

Referenced by FUNCTION().

CMuxAlarm MuxAlarm

Definition at line 29 of file timeutil.cpp.

Referenced by boot_slave(), check_filter(), compile_regex(), did_it(), do_command(), do_mail_review(), dump_database(), eval_boolexp(), filter_handler(), fork_and_dump(), FUNCTION(), grep_util(), CHashFile::Insert(), list_check(), match(), modSpeech(), mux_exec(), page_return(), CHashPage::ReadPage(), real_regmatch(), real_regrab(), regexp_match(), sighandler(), switch_handler(), Task_RunQueueEntry(), u_comp(), and CHashPage::WritePage().

const CLinearTimeDelta time_15m = 15*FACTOR_100NS_PER_MINUTE

Definition at line 184 of file timeutil.h.

Referenced by dispatch_CheckEvents().

const CLinearTimeDelta time_15s = 15*FACTOR_100NS_PER_SECOND

Definition at line 181 of file timeutil.h.

Referenced by init_timer().

const CLinearTimeDelta time_1s = FACTOR_100NS_PER_SECOND

Definition at line 180 of file timeutil.h.

Referenced by dump_database(), CHashFile::Insert(), CHashPage::ReadPage(), and CHashPage::WritePage().

const CLinearTimeDelta time_1w = FACTOR_100NS_PER_WEEK

Definition at line 186 of file timeutil.h.

Referenced by TIME_Initialize().

const CLinearTimeDelta time_200us = 200*FACTOR_100NS_PER_MICROSECOND

Definition at line 177 of file timeutil.h.

const CLinearTimeDelta time_250ms = 250*FACTOR_100NS_PER_MILLISECOND

Definition at line 179 of file timeutil.h.

const CLinearTimeDelta time_30m = 30*FACTOR_100NS_PER_MINUTE

Definition at line 185 of file timeutil.h.

Referenced by shovechars().

const CLinearTimeDelta time_30s = 30*FACTOR_100NS_PER_SECOND

Definition at line 182 of file timeutil.h.

Referenced by init_timer().

const CLinearTimeDelta time_45s = 45*FACTOR_100NS_PER_SECOND

Definition at line 183 of file timeutil.h.

Referenced by init_timer().

const CLinearTimeDelta time_5ms = 5*FACTOR_100NS_PER_MILLISECOND

Definition at line 178 of file timeutil.h.


Generated on Mon May 28 04:40:23 2007 for MUX by  doxygen 1.4.7