TIMELIB_API size32_t TIMELIB_CALL tlDatesForWeek(ARowBuilder& __self, unsigned int date) { struct tm timeInfo; struct TMDateRange { unsigned int startDate; unsigned int endDate; }; TMDateRange* result = reinterpret_cast<TMDateRange*>(__self.getSelf()); memset(&timeInfo, 0, sizeof(timeInfo)); tlInsertDateIntoTimeStruct(&timeInfo, date); // Call mktime once to fix up any bogus data tlMKTime(&timeInfo); // Adjust and call again timeInfo.tm_mday -= timeInfo.tm_wday; tlMKTime(&timeInfo); result->startDate = tlExtractDateFromTimeStruct(&timeInfo); // Adjust to the beginning of the week timeInfo.tm_mday += 6; tlMKTime(&timeInfo); result->endDate = tlExtractDateFromTimeStruct(&timeInfo); return static_cast<size32_t>(sizeof(TMDateRange)); }
TIMELIB_API size32_t TIMELIB_CALL tlSecondsToParts(ARowBuilder& __self, __int64 seconds) { struct tm timeInfo; struct TMParts { __int32 sec; __int32 min; __int32 hour; __int32 mday; __int32 mon; __int32 year; __int32 wday; }; tlMakeTimeStructFromUTCSeconds(seconds, &timeInfo); TMParts* result = reinterpret_cast<TMParts*>(__self.getSelf()); result->sec = timeInfo.tm_sec; result->min = timeInfo.tm_min; result->hour = timeInfo.tm_hour; result->mday = timeInfo.tm_mday; result->mon = timeInfo.tm_mon; result->year = timeInfo.tm_year; result->wday = timeInfo.tm_wday; return static_cast<size32_t>(sizeof(TMParts)); }