![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cTimeUnits.h>
Static Public Member Functions | |
static int __stdcall | IsLeapYear (TIMEUNIT_t wYear) |
static int __stdcall | GetLeapYearsSince2K (TIMEUNIT_t wYear) |
static TIMEDOW_TYPE __stdcall | GetDOW (TIMEUNIT_t wYear, TIMEUNIT_t wMonth, TIMEUNIT_t wDay) |
static int __stdcall | GetDOY (TIMEUNIT_t wYear, TIMEUNIT_t wMonth, TIMEUNIT_t wDay) |
Public Attributes | |
TIMEUNIT_t | m_wYear |
Year valid for 1980 to 2043 at least. TIMEUNIT_Year. More... | |
TIMEUNIT_t | m_wMonth |
1 based month of year. Jan=1, to 12=Dec, NOT TIMEMONTH_TYPE. TIMEUNIT_Month More... | |
TIMEUNIT_t | m_wDay |
1 based day of month. 1 to 31. TIMEUNIT_Day More... | |
TIMEUNIT_t | m_wHour |
0 to 23 for hour of day. More... | |
TIMEUNIT_t | m_wMinute |
0 to 59 More... | |
TIMEUNIT_t | m_wSecond |
0 to 59 More... | |
TIMEUNIT_t | m_wMillisecond |
1000th = thousandth. 0 to 1000 More... | |
TIMEUNIT_t | m_wMicrosecond |
1000000th = millionth. 0 to 1000. TIMEUNIT_Microsecond More... | |
TIMEUNIT_t | m_nTZ |
TZ_TYPE where m_wHour has NOT yet been adjusted. TIMEUNIT_TZ. More... | |
Static Public Attributes | |
static const TIMESECD_t | k_nSecondsPerDay = (24 * 60 * 60) |
seconds in a day = 86400 More... | |
static const TIMESECD_t | k_nSecondsPerHour = (60 * 60) |
seconds in a hour = 3600 More... | |
static const int | k_nMinutesPerDay = (24 * 60) |
minutes in a day More... | |
static const int | k_nMicroSeconds = 1000000 |
millionth of a second. More... | |
static const CTimeUnit | k_Units [TIMEUNIT_QTY] |
Metadata for time units. More... | |
static const GChar_t * | k_StrFormats [TIME_FORMAT_QTY+1] |
standard strftime() type formats. More... | |
static const BYTE | k_MonthDays [2][TIMEMONTH_QTY] |
Jan=0. More... | |
static const WORD | k_MonthDaySums [2][TIMEMONTH_QTY+1] |
Jan=0. More... | |
static const GChar_t *const | k_MonthName [TIMEMONTH_QTY+1] |
January=0. More... | |
static const GChar_t *const | k_MonthAbbrev [TIMEMONTH_QTY+1] |
Jan=0. More... | |
static const GChar_t *const | k_DayName [TIMEDOW_QTY+1] |
Sunday=0. More... | |
static const GChar_t *const | k_DayAbbrev [TIMEDOW_QTY+1] |
Sun=0. More... | |
static const GChar_t | k_TimeSeparator = ':' |
this is the same for all formats. e.g. 09:00 AM. NOT USED ? More... | |
static const GChar_t | k_Seps [3] = _GT("/:") |
static const GChar_t | k_SepsAll [8] = _GT("/ :T.,-") |
static GChar_t | sm_DateSeparator = '/' |
date separator to use for string creation = '\', '-', '.', but Time is always ':' More... | |
static bool | sm_time24Mode = false |
Display time in 24 hour format. default = false. More... | |
Friends | |
class | cTimeUnitsTests |
Decompose/Break time into units in order of size. like: struct tm for POSIX time_t. like: SYSTEMTIME for _WIN32 like: TIMESTAMP_STRUCT for SQL_TIMESTAMP, SQL_C_TIMESTAMP, SQL_DATE
|
inline |
|
inline |
void Gray::cTimeUnits::AddDays | ( | int | iDays | ) |
Add Days. Adjust for the fact that months and years are not all the same number of days.
void Gray::cTimeUnits::AddMonths | ( | int | iMonths | ) |
Add months to this structure. months are not exact time measures, but there are always 12 per year.
void Gray::cTimeUnits::AddSeconds | ( | TIMESECD_t | nSeconds | ) |
Add TimeUnits with seconds. handles very large values of seconds. Used to adjust for TZ and DST. nSeconds can be negative.
void Gray::cTimeUnits::AddTZ | ( | TZ_TYPE | nTimeZoneOffset | ) |
add TZ Offset in minutes.
COMPARE_TYPE Gray::cTimeUnits::Compare | ( | cTimeUnits & | b | ) | const |
Compare relevant parts of 2 times.
|
inline |
|
inline |
|
inline |
UINT32 Gray::cTimeUnits::get_DosDate | ( | ) | const |
get/pack a 32 bit DOS date format. for ZIP files. and old FAT file system. ASSUME isValidTimeUnits().
|
inline |
Calculated Day of Week
|
inline |
Day of year. 0 based
|
inline |
|
inline |
|
static |
|
static |
Day of the year. 0 to 365 wMonth = 1 based wDay = 1 based.
StrLen_t Gray::cTimeUnits::GetFormStr | ( | GChar_t * | pszOut, |
StrLen_t | iOutSizeMax, | ||
const GChar_t * | pszFormat | ||
) | const |
Get the time as a formatted string using "C" strftime() build formatted string from cTimeUnits. similar to C stdlib strftime() http://linux.die.net/man/3/strftime add TZ as postfix if desired?? used by cTimeDouble::GetTimeFormStr and cTimeInt::GetTimeFormStr
|
inline |
|
static |
calculate the number of leap days/years since Jan 1 of a year to Jan 1 2000. (Jan 1 2000 = TIMEDOW_Sat) to Jan 1 wYear can be negative if wYear < 2000
StrLen_t Gray::cTimeUnits::GetTimeSpanStr | ( | GChar_t * | pszOut, |
StrLen_t | iOutSizeMax, | ||
TIMEUNIT_TYPE | eUnitHigh = TIMEUNIT_Day , |
||
int | iUnitsDesired = 2 , |
||
bool | bShortText = false |
||
) | const |
A delta/span time string. from years to milliseconds. Get a text description of amount of time span (delta)
|
inline |
enumerate the time units.
|
inline |
Get the current time, and adjust units for timezone. nDST ?? like _WIN32 GetLocalTime(st), GetSystemTime(st)
bool Gray::cTimeUnits::isInDST | ( | ) | const |
Is this Date DST? Assuming local time zone honors DST. http://www.worldtimezone.com/daylight.html like the C internal function _isindst(const struct tm *tb)
rule for years >= 1987: begin after 2 AM on the first Sunday in April end 1 AM on the last Sunday in October.
rule for years >= 2007: begin Second Sunday in March 2AM end First Sunday in November 2AM
|
static |
0 or 1 NOT Boolean - for array access. Every year divisible by 4 is a leap year. But every year divisible by 100 is NOT a leap year Unless the year is also divisible by 400, then it is still a leap year.
bool Gray::cTimeUnits::isReasonableTimeUnits | ( | ) | const |
Is this data reasonable for most purposes?
bool Gray::cTimeUnits::isTimeFuture | ( | ) | const |
|
inline |
AKA Expired ?
|
inline |
bool Gray::cTimeUnits::isValidTimeUnits | ( | ) | const |
Are the values in valid range ?
bool Gray::cTimeUnits::IsValidUnit | ( | TIMEUNIT_TYPE | i | ) | const |
|
inline |
void Gray::cTimeUnits::put_DosDate | ( | UINT32 | ulDosDate | ) |
unpack 32 bit DosDate format. for ZIP files and old FAT file system. we could use DosDateTimeToFileTime and LocalFileTimeToFileTime for _WIN32 0-4 =Day of the month (1-31) 5-8 =Month (1 = January, 2 = February, and so on) 9-15 =Year offset from 1980 (add 1980 to get actual year) . 6 bits = 63 years = 2043 failure.
set cTimeUnits from a string.
e.g. "Sat, 07 Aug 2004 01:20:20", "" toJSON method: "2012-04-23T18:25:43.511Z" is sortable.0 length = OK, <=0 = doesn't seem like a valid datetime.
|
inline |
void Gray::cTimeUnits::SetZeros | ( | ) |
|
friend |
|
static |
|
static |
|
static |
|
static |
Jan=0.
|
static |
Jan=0.
|
static |
|
static |
millionth of a second.
|
static |
minutes in a day
|
static |
seconds in a day = 86400
|
static |
seconds in a hour = 3600
|
static |
standard strftime() type formats.
|
static |
this is the same for all formats. e.g. 09:00 AM. NOT USED ?
|
static |
Metadata for time units.
TIMEUNIT_t Gray::cTimeUnits::m_nTZ |
TZ_TYPE where m_wHour has NOT yet been adjusted. TIMEUNIT_TZ.
TIMEUNIT_t Gray::cTimeUnits::m_wDay |
1 based day of month. 1 to 31. TIMEUNIT_Day
TIMEUNIT_t Gray::cTimeUnits::m_wHour |
0 to 23 for hour of day.
TIMEUNIT_t Gray::cTimeUnits::m_wMicrosecond |
1000000th = millionth. 0 to 1000. TIMEUNIT_Microsecond
TIMEUNIT_t Gray::cTimeUnits::m_wMillisecond |
1000th = thousandth. 0 to 1000
TIMEUNIT_t Gray::cTimeUnits::m_wMinute |
0 to 59
TIMEUNIT_t Gray::cTimeUnits::m_wMonth |
1 based month of year. Jan=1, to 12=Dec, NOT TIMEMONTH_TYPE. TIMEUNIT_Month
TIMEUNIT_t Gray::cTimeUnits::m_wSecond |
0 to 59
TIMEUNIT_t Gray::cTimeUnits::m_wYear |
Year valid for 1980 to 2043 at least. TIMEUNIT_Year.
|
static |
date separator to use for string creation = '\', '-', '.', but Time is always ':'
might be . for Germans,
|
static |
Display time in 24 hour format. default = false.