/** *time64_to_tm-convertsthecalendartimetolocalbroken-downtime * *@totalsecs:thenumberofsecondselapsedsince00:00:00onJanuary1,1970, *CoordinatedUniversalTime(UTC). *@offset:offsetsecondsaddingtototalsecs. *@result:pointertostructtmvariabletoreceivebroken-downtime
*/ void time64_to_tm(time64_t totalsecs, int offset, struct tm *result)
{
u32 u32tmp, day_of_century, year_of_century, day_of_year, month, day;
u64 u64tmp, udays, century, year; bool is_Jan_or_Feb, is_leap_year; long days, rem; int remainder;
days = div_s64_rem(totalsecs, SECS_PER_DAY, &remainder);
rem = remainder;
rem += offset; while (rem < 0) {
rem += SECS_PER_DAY;
--days;
} while (rem >= SECS_PER_DAY) {
rem -= SECS_PER_DAY;
++days;
}
result->tm_hour = rem / SECS_PER_HOUR;
rem %= SECS_PER_HOUR;
result->tm_min = rem / 60;
result->tm_sec = rem % 60;
/* January 1, 1970 was a Thursday. */
result->tm_wday = (4 + days) % 7; if (result->tm_wday < 0)
result->tm_wday += 7;
/* Convert to the Gregorian calendar and adjust to Unix time. */
year = year + is_Jan_or_Feb - 6313183731940000ULL;
month = is_Jan_or_Feb ? month - 12 : month;
day = day + 1;
day_of_year += is_Jan_or_Feb ? -306 : 31 + 28 + is_leap_year;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.