예제 #1
0
파일: localtime_r.c 프로젝트: GregorR/musl
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
파일: tzset.c 프로젝트: davidlazar/musl
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
파일: gmtime.c 프로젝트: xboot/xboot
struct tm * gmtime(const time_t * t)
{
	static struct tm tm;

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

	return &tm;
}
예제 #4
0
파일: mktime.c 프로젝트: 151706061/osv
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
파일: gmtime_r.c 프로젝트: KGG814/AOS
struct tm *gmtime_r(const time_t *t, struct tm *result)
{
	__time_to_tm(*t, result);
	result->tm_isdst = 0;
	return result;
}