22 const char*
DateType::monthlyNames[] =
40 const char*
DateType::monthlyShortNames[] =
76 const short DateType::daysYTDforMonth[] =
99 for (month = 1; month < 13; month++)
118 if ((month < 1) || (month > 12))
127 return daysInEachMonth[month];
136 if ((month < 1) || (month > 12))
140 return daysYTDforMonth[month - 1];
144 return daysYTDforMonth[month - 1] + 1;
148 return daysYTDforMonth[month - 1];
201 if ((m > 0) && (m < 13))
204 d = (uchar)atoi (field2.Str ());
205 y = (
short)atoi (field3.Str ());
218 if ((m > 0) && (m < 13))
221 kkint32 f3 = atoi (field3.Str ());
222 kkint32 f1 = atoi (field1.Str ());
249 kkint32 f1 = atoi (field1.Str ());
250 kkint32 f2 = atoi (field2.Str ());
251 kkint32 f3 = atoi (field3.Str ());
253 if (((f1 >= 1) && (f1 <= 12)) &&
254 ((f2 >= 1) && (f2 <= 31)) &&
255 ((f3 >= 0) && (f3 <= 9999))
267 if (((f1 >= 0) && (f1 <= 9999)) &&
268 ((f2 >= 1) && (f2 <= 12)) &&
269 ((f3 >= 1) && (f3 <= 31))
280 if (((f1 >= 0) && (f1 <= 31)) &&
281 ((f2 >= 1) && (f2 <= 12)) &&
282 ((f3 >= 1) && (f3 <= 9999))
313 SetFromNumOfDaysInTime (days);
325 kkint32 numOf4Years = days / 1461;
330 year = (
short)(numOf4Years * 4);
346 while (days > daysInYear)
349 days = days - daysInYear;
355 while (days > daysInMonth)
358 days = days - daysInMonth;
392 SetFromNumOfDaysInTime (numDays);
425 SetFromNumOfDaysInTime (numDays);
448 kkint32 newMonth = month + _months;
449 year = year + (
short)(newMonth / 12);
450 newMonth = newMonth % 12;
477 if ((month < 1) || (month > 12))
486 totDays = totDays - ((x * 365) + (x / 4));
491 totDays += (year * 365) + ((year - 1) / 4) + 1;
519 if (year > right.year)
522 else if (year < right.year)
525 else if (month > right.month)
528 else if (month < right.month)
531 else if (day > right.day)
534 else if (day < right.day)
544 return (Compare (right) == 0);
550 return (Compare (right) != 0);
557 return (Compare (right) > 0);
564 return (Compare (right) >= 0);
571 return (Compare (right) < 0);
579 return (Compare (right) <= 0);
589 years += (months / 12);
590 months = (months % 12);
594 while ((days < 1) && (days > daysInTheMonth))
604 days = days + daysInTheMonth;
612 days = days - daysInTheMonth;
680 if ((month < 1) || (month > 12))
683 s << monthlyShortNames[month];
714 const char* monthStr =
"***";
715 if ((month >= 1) && (month <= 12))
716 monthStr = monthlyShortNames[month];
747 std::ostream&
KKB::operator<< ( std::ostream& os,
768 minute (_time.minute),
769 second (_time.second)
787 kkint32 hours = seconds / 3600;
788 seconds = seconds % 3600;
790 kkint32 minutes = seconds / 60;
791 seconds = seconds % 60;
794 minute = (
uchar)minutes;
795 second = (
uchar)seconds;
808 KKStr field1, field2, field3;
823 kkint32 f1 = atoi (field1.Str ());
824 kkint32 f2 = atoi (field2.Str ());
825 kkint32 f3 = atoi (field3.Str ());
828 if (((f1 >= 0) && (f1 <= 24)) &&
829 ((f2 >= 0) && (f2 <= 59)) &&
830 ((f3 >= 0) && (f3 <= 59))
855 if (hour > right.hour)
858 else if (hour < right.hour)
861 else if (minute > right.minute)
864 else if (minute < right.minute)
867 else if (second > right.second)
870 else if (second < right.second)
882 minute = right.minute;
883 second = right.second;
892 return (Compare (right) == 0);
899 return (Compare (right) == 0);
907 return (Compare (right) > 0);
914 return (Compare (right) >= 0);
921 return (Compare (right) < 0);
927 return hour * 3600 + minute * 60 + second;
933 return (
double)hour + (
double)(minute * 60 + second) / 3600.0;
939 return (
double)hour + (
double)(minute * 60 + second) / 60.0;
963 return (Compare (right) <= 0);
982 std::ostream&
KKB::operator<< ( std::ostream& os,
1007 date
(dateTime.date
),
1008 time
(dateTime.time
) 1035 date
(_year
, _month
, _day
),
1036 time
(_hour
, _minute
, _second
) 1061 KKStr dateStr = datePart1
+ "/" + datePart2
+ "/" + datePart3;
1081 if (date
< right.date)
1084 else if (date
> right.date)
1087 return time.Compare (right.time);
1096 return secsInDate + secsInTime;
1129 while (newHour > 23)
1149 while (newMins >= 60)
1163 long minsToAdd = newSecs / 60;
1164 newSecs = newSecs - (minsToAdd * 60);
1174 while (newSecs >= 60)
1243 return Compare (right) == 0;
1250 return Compare (right) != 0;
1257 return Compare (right) > 0;
1264 return Compare (right) >= 0;
1270 return Compare (right) < 0;
1276 return Compare (right) <= 0;
1285 netSecs = netSecs % 86400;
1300 while (rightSecs > leftSecs)
1303 leftSecs = leftSecs + 86400;
1306 kkint32 netSecs = leftSecs - rightSecs;
1308 kkint32 numOfDaysInSecs = netSecs / 86400;
1309 netSecs = netSecs % 86400;
1330 std::ostream&
KKB::operator<< ( std::ostream& os,
bool operator>(const DateTime &right) const
bool operator==(const TimeType &right) const
KKStr(kkint32 size)
Creates a KKStr object that pre-allocates space for 'size' characters.
void AddMinutes(kkint32 _mins)
bool operator==(const DateType &right) const
bool operator<=(const DateTime &right) const
bool operator>=(const DateType &right) const
void AddDays(kkint32 _days)
KKStr YYYYMMDDHHMMSS() const
bool operator<(const DateTime &right) const
DateType operator-(kkint32 right) const
DateTime operator+(const DateTime &right) const
double ToHours() const
summary>Number seconds since "0000/01/01 00:00:00"
void AddSeconds(long _secs)
void MinutesAdd(kkint32 _mins)
bool operator==(const DateTime &right) const
kkint32 CountInstancesOf(char ch) const
KKStr YYYYMMDD() const
Convert into displayable string; ex: 20110517.
bool operator<=(const TimeType &right) const
TimeType & operator=(const TimeType &right)
KKStr GetNextToken(const char *delStr="\n\t\r ")
Extract next Token from string, tokens will be separated by delimiter characters. ...
KKStr ExtractToken(const char *delStr="\n\t\r ")
DateType(short _year, uchar _month, uchar _day)
summary> Constructs a date from an integer that represents the total number of days since 1/1/0000 */...
DateType(const DateType &_date)
void HoursAdd(kkint32 hours)
Add _hours to DateTime, will adjust date to accommodate 24 hour clock.
void SubtractDays(kkint32 _days)
TimeType(kkint32 seconds)
bool operator!=(const TimeType &right) const
DateType operator-(const DateType &right) const
KKStr YYYY_MM_DD() const
Convert into displayable string; ex: 20011/05/17.
KKStr YY_MM_DD() const
Convert into displayable string; ex: 11/05/17.
kkuint64 ToSeconds() const
KKStr MMM_DD_YYYY() const
Convert into displayable string; ex: May/02/2010.
void AddDays(kkint32 _days)
static uchar MonthFromStr(const KKStr &monthStr)
KKStr operator+(const char *right) const
unsigned __int32 kkuint32
static uchar DaysInTheMonth(kkint32 year, uchar month)
KKStr & operator=(KKStr &&src)
const KKB::DateType & Date() const
bool operator>(const TimeType &right) const
kkuint32 Len() const
Returns the number of characters in the string.
bool operator>(const DateType &right) const
bool operator<=(const DateType &right) const
bool operator<(const DateType &right) const
KKStrParser(const KKStr &_str)
void AddHours(kkint32 _hours)
DateType operator+(kkint32 right) const
kkuint64 ToSeconds() const
void Second(uchar _second)
static kkint32 DaysYTDforMonth(kkint32 year, uchar month)
DateType & operator=(const DateType &right)
KKStr SubStrPart(kkint32 firstChar, kkint32 lastChar) const
returns a SubString consisting of all characters starting at index 'firstChar' and ending at 'lastInd...
DateTime operator-(const DateTime &right) const
bool operator<(const TimeType &right) const
unsigned char uchar
Unsigned character.
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of 'std::string' strings.
DateTime(short _year, uchar _month, uchar _day, uchar _hour, uchar _minute, uchar _second)
bool operator>=(const TimeType &right) const
DateTime(const DateTime &dateTime)
Represents a Time, consisting of three fields, Hour, Minute, and Second. summary>Represents Date and ...
unsigned __int64 kkuint64
kkint32 DaysInYear(kkint32 year)
KKStr StrFormatInt(kkint32 val, const char *mask)
KKStr YYYY_MM_DD_HH_MM_SS() const
std::ostream &__cdecl operator<<(std::ostream &os, const KKStr &str)
KKStr operator+(const KKStr &right) const
uchar DaysThisMonth() const
returns the number of days in 'month' and if leapYear and February returns 29.
TimeType operator+(const TimeType &right) const
DateType operator+(const DateType &right) const
bool operator!=(const DateType &right) const
TimeType(const TimeType &time)
void SecondsAdd(long _secs)
TimeType operator-(const TimeType &right) const
Class that manages the extraction of tokens from a String without being destructive to the original s...
void Minute(uchar _minute)
bool operator!=(const DateTime &right) const
KKStr YYYY_MMM_DD() const
Convert into displayable string; ex: 20011/May/17.
TimeType(uchar _hour, uchar _minute, uchar _second)
bool operator>=(const DateTime &right) const
Represents a calendar date consisting of three fields, Year, Month, and Day.
kkint32 CompareIgnoreCase(const char *s2) const
summary>Compares to Strings and returns -1, 0, or 1, indicating if less than, equal, or greater.
DateTime(const DateType &_date, const TimeType &_time)
DateTime & operator=(const DateTime &right)
const TimeType & Time() const
void AddMonths(kkint32 _months)