generated from Jaysyn/ModuleTemplate
97 lines
2.1 KiB
Plaintext
97 lines
2.1 KiB
Plaintext
//::///////////////////////////////////////////////
|
|
//:: Name Persistent World Clock
|
|
//:: FileName ld_clock_inc
|
|
//:://////////////////////////////////////////////
|
|
/*
|
|
This is the core function include for my
|
|
PW clock system.
|
|
*/
|
|
//:://////////////////////////////////////////////
|
|
//:: Created By: Lord Delekhan
|
|
//:: Created On: March 17, 2005
|
|
//:://////////////////////////////////////////////
|
|
struct Date
|
|
{
|
|
int Hour;
|
|
int Day;
|
|
int Month;
|
|
int Year;
|
|
};
|
|
|
|
// converts date back to seperate values
|
|
struct Date DecodeDate(int iDate);
|
|
// converts hour, day, month, and year values into a single value for storage
|
|
int EncodeDate(struct Date D);
|
|
// returns the current date in encoded form
|
|
int GetCurrentDate();
|
|
// returns the difference between StartDate and the current date
|
|
// in the structure Date format
|
|
struct Date ElapsedTime(int StartDate);
|
|
// stores the current date
|
|
void SetSavedDate(int iValue);
|
|
// gets the saved date
|
|
int GetSavedDate();
|
|
// Functions Begin Here
|
|
|
|
struct Date DecodeDate(int iDate)
|
|
{
|
|
struct Date D;int M, H;
|
|
D.Year = iDate / 8064;
|
|
M = iDate % 8064;
|
|
D.Month = M / 672;
|
|
H = M % 672;
|
|
D.Day = H / 24;
|
|
D.Hour = H % 24;
|
|
return D;
|
|
}
|
|
|
|
int EncodeDate(struct Date D)
|
|
{
|
|
int iDate = (D.Year*8064)+(D.Month*672)+(D.Day*24)+D.Hour;
|
|
return iDate;
|
|
}
|
|
|
|
int GetCurrentDate()
|
|
{
|
|
struct Date D;
|
|
D.Year = GetCalendarYear();
|
|
D.Month = GetCalendarMonth();
|
|
D.Day = GetCalendarDay();
|
|
D.Hour = GetTimeHour();
|
|
int iDate = EncodeDate(D);
|
|
return iDate;
|
|
}
|
|
|
|
struct Date ElapsedTime(int StartDate)
|
|
{
|
|
struct Date D;int iDate;
|
|
iDate = GetCurrentDate() - StartDate;
|
|
D = DecodeDate(iDate);
|
|
return D;
|
|
}
|
|
|
|
void SetSavedDate(int iValue)
|
|
{
|
|
object oMod = GetModule();
|
|
SetCampaignInt("LDClock","CurrentDate",iValue,oMod);
|
|
}
|
|
|
|
int GetSavedDate()
|
|
{
|
|
object oMod = GetModule();
|
|
return GetCampaignInt("LDClock","CurrentDate",oMod);
|
|
}
|
|
|
|
int GetDateInitialized()
|
|
{
|
|
object oMod = GetModule();
|
|
return GetCampaignInt("LDClock","DateStored",oMod);
|
|
}
|
|
|
|
void InitializeDate()
|
|
{
|
|
object oMod = GetModule();
|
|
SetCampaignInt("LDClock","DateStored",TRUE,oMod);
|
|
}
|
|
//void main (){}
|