9 #include "../headers/Date.h"
41 std::vector<std::string> Result =
SplitStrings(Date,
"/");
43 SetDate(std::stoi(Result[2]),std::stoi(Result[1]),std::stoi(Result[0]));
99 if (mktime(& HKtm)== -1)
103 Datetm.tm_year = Date.
GetYear() - 1900;
105 Datetm.tm_mon = Date.
GetMonth() - 1;
106 Datetm.tm_mday = Date.
GetDay();
111 if (mktime(& Datetm)== -1)
115 if(mktime(&HKtm) > mktime(&Datetm))
116 seconds = mktime(&HKtm) - mktime(&Datetm);
118 seconds = mktime(&Datetm) - mktime(&HKtm);
123 return ((seconds / 60) / 60) / 24;
134 std::string Day = std::to_string(
HK_Day);
135 std::string Month = std::to_string(
HK_Month);
136 std::string Year = std::to_string(
HK_Year);
144 return Year + Separator + Month + Separator + Day;
147 return Day + Separator + Month + Separator + Year;
150 return Month + Separator + Day + Separator + Year;
153 return Month + Separator + Day + Separator + Year;
169 std::string Names[13] = {
"Error",
"January" ,
"February",
"March",
"April",
"May",
170 "June" ,
"July",
"August",
"September",
"October",
"November",
"December"};
176 std::string Names[13] = {
"Error",
"January" ,
"February",
"March",
"April",
"May",
177 "June" ,
"July",
"August",
"September",
"October",
"November",
"December"};
178 for (
int C = 0; C < 13; C++){
179 if(Month == Names[C]){
221 if (mktime(& mytm)== -1)
224 DayOfYear = mytm.tm_yday;
228 NewDOY = DayOfYear + Days + 1;
230 NewDOY = DayOfYear - Days + 1;
235 mytm.tm_mday = NewDOY;
240 if (mktime(& mytm)== -1)
267 if (mktime(& HKtm)== -1)
271 Datetm.tm_year = Date.
GetYear() - 1900;
273 Datetm.tm_mon = Date.
GetMonth() - 1;
274 Datetm.tm_mday = Date.
GetDay();
279 if (mktime(& Datetm)== -1)
282 if(mktime(&HKtm) < mktime(&Datetm))
303 if (mktime(& HKtm)== -1)
307 Datetm.tm_year = Date.
GetYear() - 1900;
309 Datetm.tm_mon = Date.
GetMonth() - 1;
310 Datetm.tm_mday = Date.
GetDay();
315 if (mktime(& Datetm)== -1)
318 if(mktime(&HKtm) > mktime(&Datetm))
379 int DaysInMonth[] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };
382 if((0 == ( Year % 4 ) && 0 != ( Year % 100)) || 0 == (Year % 400))
388 if(Day < 0 || Day > MonthLength)
390 if(Month < 0 || Month > 12)
402 time_t t = time(NULL);
403 tm* timePtr = localtime(&t);
405 HK_Day = timePtr->tm_mday;
407 HK_Year = timePtr->tm_year + 1900;
415 time_t Hold = mktime(&TimeIn);
417 tm * TimeOut = localtime(&Hold);
419 return TimeOut->tm_wday;
434 int Days[] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };
446 std::vector<std::string> OutArray;
449 for(
unsigned int a = 0; a < In.length(); a++) {
450 if(In[a] == Split[0]) {
451 OutArray.push_back(Hold);
455 Hold.push_back(In[a]);
457 OutArray.push_back(Hold);
const int HK_DateMode_YMD
const int HK_DateMode_MDY
const int HK_DateMode_DMY
A Class For Managing Dates.
int GetMonth()
Returns Month Value.
int HK_Month
Holds The Month Part Of The Date.
void SetMonth(int Month)
Sets Month Value, Doesn't Check If Its Valid.
int Difference(HK_Date Date)
Returns The Number Of Days Difference Between This HK_Date And The Supplied Date.
bool IsEqualMonth(HK_Date Date)
Checks To See If The Input Date's Month and Year Is Same As Stored Date.
bool IsLeapYear()
Returns True If HK_Year Is A Leap Year.
std::string MonthName()
Returns HK_Month's Name As String.
int HK_Year
Holds The Year Part Of The Date.
void Reset()
Resets Date To Today.
std::string ToSortable(std::string Separator)
Generate A Sortable String For Database.
bool SubtractDays(int Days)
Subtracts Days To This HK_Date.
bool IsBefore(HK_Date Date)
Checks To See If The Input Date Is Before The Stored Date.
void SetDay(int Days)
Sets Day Value, Doesn't Check If Its Valid.
std::string ToReadable(std::string Separator, int Mode)
Generate A Readable String.
int StartDayOfWeek()
Returns What Day Of The Week This HK_Date Month Starts.
bool AddDays(int Days)
Adds Days To This HK_Date.
bool IsEqualYear(HK_Date Date)
Checks To See If The Input Date's Year Is Same As Stored Date.
int HK_Day
Holds The Day Part Of The Date.
bool IsValid()
Checks If This HK_Date Contains A Valid Date.
int GetDay()
Returns Day Value.
std::string IntToMonth(int Month)
Returns The Selected Month Name As A String. Expects 1 - 12.
HK_Date()
The Default Constructor. Sets Date To Today.
bool IsValidDate(int Days, int Month, int Year)
Takes Day, Month And Year And Generates A Readable String.
bool IsEqual(HK_Date Date)
Checks To See If The Input Date Is Same As Stored Date.
bool ModifyDate(int Days, bool Operator)
Adds Or Subtracts Days From This HK_Date.
int DaysInMonth()
Returns The Number Of Days In HK_Month. LeapYear Is Checked.
bool SetDate(int Days, int Month, int Year)
Sets Day, Month, and Year.
bool IsAfter(HK_Date Date)
Checks To See If The Input Date Is After The Stored Date.
int GetYear()
Returns Year Value.
void SetYear(int Year)
Sets Year Value, Doesn't Check If Its Valid.
std::vector< std::string > SplitStrings(std::string In, std::string Split)
Splits In By Split And Returns A Vector With Data.
int MonthToInt(std::string Month)
Converts Month Name To An Int.