//:://///////////////////////////////////////////// //:: Name - Time Functions Include File //:: FileName - uth__inc_time //::////////////////////////////////////////////// /* General Time Functions */ //::////////////////////////////////////////////// //:: Created By: Ralf Schemmann //:: Created On: 11.10.2003 // //:: Modified by: Bill Jones 7-Feb-2005 to add MAX_UPTIME and SendMessageToAllPCs //::////////////////////////////////////////////// // CONSTANTS const int MAX_UPTIME = 12; // number of hours until NWman restarts mod const int THAIN_MINUTES_PER_HOUR = 2; const string THAIN_TIME_DATABASE = "Thain_Time_DB"; const string THAIN_CURRENT_DATE = "Thain_Current_Date"; //------------------------------------- // INTERFACE // Gets ModuleTime in Minutes int GetTimeInMinutes(); // Sets Module Time from Minutes Value void SetTimeFromMinutes(int nTimeMinutes); // Sends a Message to All PCs void SendMessageToAllPCs(string sMsg); //------------------------------------- // IMPLEMENTATION int GetTimeInMinutes() { int nTime = GetTimeMinute() + (GetTimeHour() * THAIN_MINUTES_PER_HOUR) + (GetCalendarDay() * THAIN_MINUTES_PER_HOUR * 24) + (GetCalendarMonth() * THAIN_MINUTES_PER_HOUR * 24 * 28) + (GetCalendarYear() * THAIN_MINUTES_PER_HOUR * 24 * 28 * 12); return nTime; } //------------------------------------- void SetTimeFromMinutes(int nTimeMinutes) { int nYear = nTimeMinutes/(THAIN_MINUTES_PER_HOUR * 24 * 28 * 12); nTimeMinutes = nTimeMinutes - (nYear * THAIN_MINUTES_PER_HOUR * 24 * 28 * 12); int nMonth = nTimeMinutes/(THAIN_MINUTES_PER_HOUR * 24 * 28); nTimeMinutes = nTimeMinutes - (nMonth * THAIN_MINUTES_PER_HOUR * 24 * 28); int nDay = nTimeMinutes/(THAIN_MINUTES_PER_HOUR * 24); nTimeMinutes = nTimeMinutes - (nDay * THAIN_MINUTES_PER_HOUR * 24); int nHour = nTimeMinutes/(THAIN_MINUTES_PER_HOUR); nTimeMinutes = nTimeMinutes - (nHour * THAIN_MINUTES_PER_HOUR); int nMinute = nTimeMinutes; SetCalendar(nYear, nMonth, nDay); SetTime(nHour, nMinute, 0, 0); } //------------------------------------- void SendMessageToAllPCs(string sMsg) { object oPC = GetFirstPC(); while (oPC != OBJECT_INVALID) { SendMessageToPC(oPC, sMsg); oPC = GetNextPC(); } } //-------------------------------------