Exemple #1
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;
}
Exemple #2
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;
}
Exemple #3
0
time_t timegm(struct tm *tm)
{
	return __tm_to_time(tm);
}
Exemple #4
0
time_t mktime(struct tm * tm)
{
	return __tm_to_time(tm);
}