Пример #1
0
struct tm *localtime_r(const time_t *t, struct tm *result)
{
	__tzset();
	__time_to_tm(*t - __timezone, result);
	result->tm_isdst = -1;
	return __dst_adjust(result);
}
Пример #2
0
struct tm *__dst_adjust(struct tm *tm)
{
    time_t t;
    int start, end, secs;
    int after_start, before_end;

    if (tm->tm_isdst >= 0) return tm;
    if (!__daylight) {
        tm->tm_isdst = 0;
        return tm;
    }

    secs = tm->tm_hour*3600 + tm->tm_min*60 + tm->tm_sec;
    start = cutoff_yday(tm, &__dst_start);
    end = cutoff_yday(tm, &__dst_end);

    after_start = (tm->tm_yday > start || (tm->tm_yday == start && secs >= __dst_start.time));
    before_end = (tm->tm_yday < end || (tm->tm_yday == end && secs < __dst_end.time));

    if ((after_start && before_end) || ((end < start) && (after_start || before_end))) {
        tm->tm_sec -= __dst_offset;
        tm->tm_isdst = 1;
        t = __tm_to_time(tm);
        return __time_to_tm(t, tm);
    } else tm->tm_isdst = 0;

    return tm;
}
Пример #3
0
struct tm * gmtime(const time_t * t)
{
	static struct tm tm;

	__time_to_tm(*t, &tm);
	tm.tm_isdst = 0;

	return &tm;
}
Пример #4
0
time_t mktime(struct tm *tm)
{
	int isdst = tm->tm_isdst;
	time_t t, lt;

	__tzset();

	tm->tm_sec += __timezone;
	if (isdst > 0) tm->tm_sec += __dst_offset;

	t = __tm_to_time(tm);
	
	lt = t - __timezone;
	if (isdst > 0) lt -= __dst_offset;
	__time_to_tm(lt, tm);

	__dst_adjust(tm);
	
	return t;
}
Пример #5
0
struct tm *gmtime_r(const time_t *t, struct tm *result)
{
	__time_to_tm(*t, result);
	result->tm_isdst = 0;
	return result;
}